author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
305,159
02.12.2019 10:50:43
-3,600
029cc744cec0f0042e914e138c03424e6625e5df
remove client factory, preffer builtins in rollup
[ { "change_type": "MODIFY", "old_path": "rollup.config.js", "new_path": "rollup.config.js", "diff": "@@ -10,7 +10,7 @@ import tsc from 'typescript'\nconst pkg = require('./package.json')\nlet plugins = [\n- resolve({}),\n+ resolve({preferBuiltins: true}),\ncommonjs(),\nbuiltins(),\nsourceMaps(),\n" }, { "change_type": "MODIFY", "old_path": "src/client/InfluxDBClient.ts", "new_path": "src/client/InfluxDBClient.ts", "diff": "import WriteApi from './WriteApi'\n+import {ClientOptions} from './options'\n+import WriteApiImpl from './impl/WriteApiImpl'\n/**\n* InfluxDB 2.0 client that uses HTTP API described in https://v2.docs.influxdata.com/v2.0/reference/api/ .\n*/\n-export default interface InfluxDBClient {\n- getWriteApi(): WriteApi\n+export class InfluxDBClient {\n+ constructor(private options: ClientOptions) {}\n+ getWriteApi(): WriteApi {\n+ return new WriteApiImpl(this.options)\n+ }\n}\n" }, { "change_type": "DELETE", "old_path": "src/client/InfluxDBClientFactory.ts", "new_path": null, "diff": "-/**\n- * Factory that creates an instance of a InfluxDB 2.0 client.\n- */\n-export class InfluxDBClientFactory {\n- public static create(): void {\n- // TODO return InfluxDBClient\n- }\n-}\n" }, { "change_type": "DELETE", "old_path": "src/client/impl/InfluxDBClientImpl.ts", "new_path": null, "diff": "-import InfluxDBClient from '../InfluxDBClient'\n-import {ClientOptions} from '../options'\n-import WriteApi from '../WriteApi'\n-import WriteApiImpl from './WriteApiImpl'\n-\n-export class InfluxDBClientImpl implements InfluxDBClient {\n- constructor(private options: ClientOptions) {}\n- public getWriteApi(): WriteApi {\n- return new WriteApiImpl(this.options)\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/client/impl/NodeHttpTransport.ts", "diff": "import {ConnectionOptions} from '../options'\n-import {URL} from 'url'\n+import {parse} from 'url'\nimport * as http from 'http'\nimport * as https from 'https'\nimport {Buffer} from 'buffer'\n@@ -81,7 +81,7 @@ export class NodeHttpTransport {\n* @param connectionOptions client options\n*/\nconstructor(connectionOptions: ConnectionOptions | {[key: string]: any}) {\n- const url = new URL(connectionOptions.url)\n+ const url = parse(connectionOptions.url)\nthis.defaultOptions = {\n...DEFAULT_OPTIONS,\n...connectionOptions,\n" }, { "change_type": "MODIFY", "old_path": "src/client/index.ts", "new_path": "src/client/index.ts", "diff": "+import {InfluxDBClient} from './InfluxDBClient'\n+\nexport * from './InfluxDBClient'\n-export * from './InfluxDBClientFactory'\nexport * from './options'\nexport * from './errors'\nexport * from './WriteApi'\n+export default InfluxDBClient\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
remove client factory, preffer builtins in rollup
305,159
02.12.2019 11:29:02
-3,600
253b87219901db9a4e1bea4b77495b78259a51c6
include authorization token in transport
[ { "change_type": "MODIFY", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/client/impl/NodeHttpTransport.ts", "diff": "@@ -80,7 +80,9 @@ export class NodeHttpTransport {\n* Creates a node transport using for the client options supplied.\n* @param connectionOptions client options\n*/\n- constructor(connectionOptions: ConnectionOptions | {[key: string]: any}) {\n+ constructor(\n+ private connectionOptions: ConnectionOptions | {[key: string]: any}\n+ ) {\nconst url = parse(connectionOptions.url)\nthis.defaultOptions = {\n...DEFAULT_OPTIONS,\n@@ -146,6 +148,7 @@ export class NodeHttpTransport {\nmethod,\nheaders: {\n'content-type': 'text/plain; charset=utf-8',\n+ authorization: 'Token ' + this.connectionOptions.token,\n...headers,\n},\nbody: bodyBuffer,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
include authorization token in transport
305,159
02.12.2019 11:45:58
-3,600
85a718a3a89cd8ed336a4c7285f809adb3520499
add simple documentation generator using typedoc
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "node_modules\n.vscode\ndist\n+coverage\n+doc\n.rpt2_cache\n.DS_Store\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"main\": \"dist/index.js\",\n\"module\": \"dist/index.mjs\",\n\"scripts\": {\n- \"build\": \"rimraf dist && NODE_ENV=production rollup -c\",\n+ \"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n+ \"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n+ \"clean\": \"rimraf coverage doc dist\",\n\"test\": \"yarn run lint && yarn run typecheck\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n\"lint\": \"eslint 'src/**/*.ts'\",\n\"rollup-plugin-sourcemaps\": \"^0.4.2\",\n\"rollup-plugin-terser\": \"^5.1.2\",\n\"rollup-plugin-typescript2\": \"^0.25.2\",\n+ \"typedoc\": \"^0.15.3\",\n\"typescript\": \"^3.7.2\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "version \"7.0.3\"\nresolved \"https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636\"\n+\"@types/[email protected]\":\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d\"\n+\n\"@types/node@*\":\nversion \"12.12.14\"\nresolved \"https://registry.yarnpkg.com/@types/node/-/node-12.12.14.tgz#1c1d6e3c75dba466e0326948d56e8bd72a1903d2\"\n@@ -146,6 +150,12 @@ atob@^2.1.1:\nversion \"2.1.2\"\nresolved \"https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9\"\n+backbone@^1.4.0:\n+ version \"1.4.0\"\n+ resolved \"https://registry.yarnpkg.com/backbone/-/backbone-1.4.0.tgz#54db4de9df7c3811c3f032f34749a4cd27f3bd12\"\n+ dependencies:\n+ underscore \">=1.8.3\"\n+\nbalanced-match@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767\"\n@@ -289,7 +299,7 @@ [email protected]:\nversion \"1.1.3\"\nresolved \"https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25\"\n-commander@^2.20.0:\n+commander@^2.20.0, commander@~2.20.3:\nversion \"2.20.3\"\nresolved \"https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33\"\n@@ -620,7 +630,7 @@ foreach@~2.0.1:\nversion \"2.0.5\"\nresolved \"https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99\"\[email protected]:\[email protected], fs-extra@^8.1.0:\nversion \"8.1.0\"\nresolved \"https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0\"\ndependencies:\n@@ -652,7 +662,7 @@ glob-parent@^5.0.0:\ndependencies:\nis-glob \"^4.0.1\"\n-glob@^7.1.3, glob@^7.1.6:\n+glob@^7.0.0, glob@^7.1.3, glob@^7.1.6:\nversion \"7.1.6\"\nresolved \"https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6\"\ndependencies:\n@@ -673,6 +683,16 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0:\nversion \"4.2.3\"\nresolved \"https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423\"\n+handlebars@^4.5.3:\n+ version \"4.5.3\"\n+ resolved \"https://registry.yarnpkg.com/handlebars/-/handlebars-4.5.3.tgz#5cf75bd8714f7605713511a56be7c349becb0482\"\n+ dependencies:\n+ neo-async \"^2.6.0\"\n+ optimist \"^0.6.1\"\n+ source-map \"^0.6.1\"\n+ optionalDependencies:\n+ uglify-js \"^3.1.4\"\n+\nhas-flag@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd\"\n@@ -691,6 +711,10 @@ hash.js@^1.0.0, hash.js@^1.0.3:\ninherits \"^2.0.3\"\nminimalistic-assert \"^1.0.1\"\n+highlight.js@^9.16.2:\n+ version \"9.16.2\"\n+ resolved \"https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.16.2.tgz#68368d039ffe1c6211bcc07e483daf95de3e403e\"\n+\nhmac-drbg@^1.0.0:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1\"\n@@ -757,6 +781,10 @@ inquirer@^7.0.0:\nstrip-ansi \"^5.1.0\"\nthrough \"^2.3.6\"\n+interpret@^1.0.0:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296\"\n+\nis-extglob@^2.1.1:\nversion \"2.1.1\"\nresolved \"https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2\"\n@@ -820,6 +848,10 @@ jest-worker@^24.6.0:\nmerge-stream \"^2.0.0\"\nsupports-color \"^6.1.0\"\n+jquery@^3.4.1:\n+ version \"3.4.1\"\n+ resolved \"https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2\"\n+\njs-tokens@^4.0.0:\nversion \"4.0.0\"\nresolved \"https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499\"\n@@ -946,6 +978,10 @@ ltgt@^2.1.2:\nversion \"2.2.1\"\nresolved \"https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5\"\n+lunr@^2.3.8:\n+ version \"2.3.8\"\n+ resolved \"https://registry.yarnpkg.com/lunr/-/lunr-2.3.8.tgz#a8b89c31f30b5a044b97d2d28e2da191b6ba2072\"\n+\nmagic-string@^0.25.2:\nversion \"0.25.4\"\nresolved \"https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.4.tgz#325b8a0a79fc423db109b77fd5a19183b7ba5143\"\n@@ -958,6 +994,10 @@ make-dir@^3.0.0:\ndependencies:\nsemver \"^6.0.0\"\n+marked@^0.7.0:\n+ version \"0.7.0\"\n+ resolved \"https://registry.yarnpkg.com/marked/-/marked-0.7.0.tgz#b64201f051d271b1edc10a04d1ae9b74bb8e5c0e\"\n+\nmd5.js@^1.3.4:\nversion \"1.3.5\"\nresolved \"https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f\"\n@@ -989,7 +1029,7 @@ minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a\"\n-minimatch@^3.0.4:\n+minimatch@^3.0.0, minimatch@^3.0.4:\nversion \"3.0.4\"\nresolved \"https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083\"\ndependencies:\n@@ -999,6 +1039,10 @@ [email protected]:\nversion \"0.0.8\"\nresolved \"https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d\"\n+minimist@~0.0.1:\n+ version \"0.0.10\"\n+ resolved \"https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf\"\n+\nmkdirp@^0.5.1:\nversion \"0.5.1\"\nresolved \"https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903\"\n@@ -1017,6 +1061,10 @@ natural-compare@^1.4.0:\nversion \"1.4.0\"\nresolved \"https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7\"\n+neo-async@^2.6.0:\n+ version \"2.6.1\"\n+ resolved \"https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c\"\n+\nnice-try@^1.0.4:\nversion \"1.0.5\"\nresolved \"https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366\"\n@@ -1049,6 +1097,13 @@ onetime@^5.1.0:\ndependencies:\nmimic-fn \"^2.1.0\"\n+optimist@^0.6.1:\n+ version \"0.6.1\"\n+ resolved \"https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686\"\n+ dependencies:\n+ minimist \"~0.0.1\"\n+ wordwrap \"~0.0.2\"\n+\noptionator@^0.8.3:\nversion \"0.8.3\"\nresolved \"https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495\"\n@@ -1151,7 +1206,7 @@ process-nextick-args@~2.0.0:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2\"\n-progress@^2.0.0:\n+progress@^2.0.0, progress@^2.0.3:\nversion \"2.0.3\"\nresolved \"https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8\"\n@@ -1221,6 +1276,12 @@ readable-stream@~1.0.26, readable-stream@~1.0.26-4:\nisarray \"0.0.1\"\nstring_decoder \"~0.10.x\"\n+rechoir@^0.6.2:\n+ version \"0.6.2\"\n+ resolved \"https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384\"\n+ dependencies:\n+ resolve \"^1.1.6\"\n+\nregexpp@^2.0.1:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f\"\n@@ -1243,7 +1304,7 @@ [email protected]:\ndependencies:\npath-parse \"^1.0.6\"\n-resolve@^1.11.0, resolve@^1.11.1:\n+resolve@^1.1.6, resolve@^1.11.0, resolve@^1.11.1:\nversion \"1.13.1\"\nresolved \"https://registry.yarnpkg.com/resolve/-/resolve-1.13.1.tgz#be0aa4c06acd53083505abb35f4d66932ab35d16\"\ndependencies:\n@@ -1412,6 +1473,14 @@ shebang-regex@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3\"\n+shelljs@^0.8.3:\n+ version \"0.8.3\"\n+ resolved \"https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.3.tgz#a7f3319520ebf09ee81275b2368adb286659b097\"\n+ dependencies:\n+ glob \"^7.0.0\"\n+ interpret \"^1.0.0\"\n+ rechoir \"^0.6.2\"\n+\nsignal-exit@^3.0.2:\nversion \"3.0.2\"\nresolved \"https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d\"\n@@ -1445,7 +1514,7 @@ source-map-url@^0.4.0:\nversion \"0.4.0\"\nresolved \"https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3\"\n-source-map@^0.6.0, source-map@~0.6.1:\n+source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:\nversion \"0.6.1\"\nresolved \"https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263\"\n@@ -1574,10 +1643,46 @@ typedarray@^0.0.6:\nversion \"0.0.6\"\nresolved \"https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777\"\n-typescript@^3.7.2:\n+typedoc-default-themes@^0.6.1:\n+ version \"0.6.1\"\n+ resolved \"https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.6.1.tgz#e2e471188983df995f4f9df49f713044fced6802\"\n+ dependencies:\n+ backbone \"^1.4.0\"\n+ jquery \"^3.4.1\"\n+ lunr \"^2.3.8\"\n+ underscore \"^1.9.1\"\n+\n+typedoc@^0.15.3:\n+ version \"0.15.3\"\n+ resolved \"https://registry.yarnpkg.com/typedoc/-/typedoc-0.15.3.tgz#8f5a038cfc1160f70cbc57e37908653483dca689\"\n+ dependencies:\n+ \"@types/minimatch\" \"3.0.3\"\n+ fs-extra \"^8.1.0\"\n+ handlebars \"^4.5.3\"\n+ highlight.js \"^9.16.2\"\n+ lodash \"^4.17.15\"\n+ marked \"^0.7.0\"\n+ minimatch \"^3.0.0\"\n+ progress \"^2.0.3\"\n+ shelljs \"^0.8.3\"\n+ typedoc-default-themes \"^0.6.1\"\n+ typescript \"3.7.x\"\n+\[email protected], typescript@^3.7.2:\nversion \"3.7.2\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb\"\n+uglify-js@^3.1.4:\n+ version \"3.7.1\"\n+ resolved \"https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.7.1.tgz#35c7de17971a4aa7689cd2eae0a5b39bb838c0c5\"\n+ dependencies:\n+ commander \"~2.20.3\"\n+ source-map \"~0.6.1\"\n+\n+underscore@>=1.8.3, underscore@^1.9.1:\n+ version \"1.9.1\"\n+ resolved \"https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961\"\n+\nuniversalify@^0.1.0:\nversion \"0.1.2\"\nresolved \"https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66\"\n@@ -1610,6 +1715,10 @@ word-wrap@~1.2.3:\nversion \"1.2.3\"\nresolved \"https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c\"\n+wordwrap@~0.0.2:\n+ version \"0.0.3\"\n+ resolved \"https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107\"\n+\nwrappy@1:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f\"\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
add simple documentation generator using typedoc
305,159
03.12.2019 12:01:26
-3,600
2716af0cac7a8060f01e57eccd5ea025d5cbae4c
add transport options to client options
[ { "change_type": "MODIFY", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/client/impl/NodeHttpTransport.ts", "diff": "@@ -86,10 +86,9 @@ export class NodeHttpTransport {\nconst url = parse(connectionOptions.url)\nthis.defaultOptions = {\n...DEFAULT_OPTIONS,\n- ...connectionOptions,\n+ ...(connectionOptions.transportOptions || {}),\nport: url.port,\nprotocol: url.protocol,\n- method: 'POST',\n}\nthis.retryJitter =\nthis.defaultOptions.retryJitter > 0 ? this.defaultOptions.retryJitter : 0\n" }, { "change_type": "MODIFY", "old_path": "src/client/options.ts", "new_path": "src/client/options.ts", "diff": "@@ -9,6 +9,8 @@ export interface ConnectionOptions {\nmaxRetries?: number\n/** include random milliseconds when retrying HTTP calls */\nretryJitter?: number\n+ /** extra options for the transport layer */\n+ transportOptions?: {[key: string]: any}\n}\n// export interface WriteOptions {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
add transport options to client options
305,159
03.12.2019 17:21:21
-3,600
426776f7c679d8008ecbdb49c54ebed1ac23473f
introduce transport as a communication interface
[ { "change_type": "MODIFY", "old_path": ".eslintrc.json", "new_path": ".eslintrc.json", "diff": "\"plugin:prettier/recommended\",\n\"prettier/@typescript-eslint\"\n],\n+ \"overrides\": [\n+ {\n+ \"files\": [\"**/*.ts\"]\n+ },\n+ {\n+ \"files\": [\"**/*.js\"],\n+ \"plugins\": [\"prettier\"]\n+ }\n+ ],\n\"rules\": {\n+ \"@typescript-eslint/camelcase\": [\"error\", {\"allow\": [\"^DEFAULT_\"]}],\n\"@typescript-eslint/no-explicit-any\": \"off\",\n\"@typescript-eslint/no-unused-vars\": [\n\"error\",\n" }, { "change_type": "MODIFY", "old_path": "rollup.config.js", "new_path": "rollup.config.js", "diff": "@@ -27,7 +27,6 @@ if (process.env.NODE_ENV === 'production') {\n}\nconst input = 'src/index.ts'\n-\nexport default [\n{\ninput,\n" }, { "change_type": "MODIFY", "old_path": "src/client/InfluxDB.ts", "new_path": "src/client/InfluxDB.ts", "diff": "@@ -3,9 +3,11 @@ import {ClientOptions, WritePrecission} from './options'\nimport WriteApiImpl from './impl/WriteApiImpl'\nimport {parse} from 'url'\nimport {IllegalArgumentError} from './errors'\n+import {Transport} from './transport'\n+import NodeHttpTransport from './impl/NodeHttpTransport'\n/**\n- * Parses the URL out into into a IClusterConfig object\n+ * Fills URL out into into a IClusterConfig object\n*/\nfunction fillOptions(\nurl: string | undefined,\n@@ -21,11 +23,19 @@ function fillOptions(\nreturn options\n}\n+/**\n+ * Creates default transport using the connection options supplied.\n+ */\n+function createTransport(options: ClientOptions): Transport {\n+ return options.transport || new NodeHttpTransport(options)\n+}\n+\n/**\n* InfluxDB 2.0 client that uses HTTP API described in https://v2.docs.influxdata.com/v2.0/reference/api/ .\n*/\nexport default class InfluxDB {\nprivate _options: ClientOptions\n+ private transport: Transport\n/* eslint-disable no-dupe-class-members */\nconstructor(url: string)\n@@ -42,13 +52,15 @@ export default class InfluxDB {\nif (!this._options.url) throw new IllegalArgumentError('No url specified!')\nif (!this._options.token)\nthrow new IllegalArgumentError('No token specified!')\n+ this.transport = createTransport(this._options)\n}\n+\n/* eslint-enable no-dupe-class-members */\ngetWriteApi(\norg: string,\nbucket: string,\nprecission: WritePrecission = WritePrecission.ms\n): WriteApi {\n- return new WriteApiImpl(this._options, org, bucket, precission)\n+ return new WriteApiImpl(this.transport, org, bucket, precission)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/client/impl/NodeHttpTransport.ts", "diff": "@@ -9,6 +9,7 @@ import {\ncanRetryHttpCall,\nHttpError,\n} from '../errors'\n+import {Cancellable, CommunicationObserver, Transport} from '../transport'\nconst DEFAULT_OPTIONS: Partial<ConnectionOptions> = {\ntimeout: 10000,\n@@ -16,36 +17,6 @@ const DEFAULT_OPTIONS: Partial<ConnectionOptions> = {\nretryJitter: 1000,\n}\n-/** Informs about changes in the communication with the server */\n-export interface CommunicationCallbacks {\n- /**\n- * Data chunk received, can be called mupliple times.\n- */\n- next(data: any): void\n- /**\n- * An error message was received.\n- */\n- error(error: Error): void\n- /**\n- * Response was fully read.\n- */\n- complete(): void\n-}\n-\n-/**\n- * Cancellation of asynchronous query.\n- */\n-export interface Cancellable {\n- /**\n- * Attempt to cancel execution of this query.\n- */\n- cancel(): void\n-\n- /**\n- * Is communication canceled.\n- */\n- isCancelled(): boolean\n-}\nclass CancellableImpl implements Cancellable {\nprivate cancelled = false\ntimeouts: Array<() => void> = []\n@@ -68,7 +39,7 @@ class CancellableImpl implements Cancellable {\n/**\n* Transport layer on top of node http or https library.\n*/\n-export class NodeHttpTransport {\n+export class NodeHttpTransport implements Transport {\nprivate defaultOptions: {[key: string]: any}\nprivate retryJitter: number\nprivate requestApi: (\n@@ -80,24 +51,25 @@ export class NodeHttpTransport {\n* Creates a node transport using for the client options supplied.\n* @param connectionOptions client options\n*/\n- constructor(\n- private connectionOptions: ConnectionOptions | {[key: string]: any}\n- ) {\n+ constructor(private connectionOptions: ConnectionOptions) {\nconst url = parse(connectionOptions.url)\nthis.defaultOptions = {\n...DEFAULT_OPTIONS,\n+ ...connectionOptions,\n...(connectionOptions.transportOptions || {}),\nport: url.port,\nprotocol: url.protocol,\n}\nthis.retryJitter =\nthis.defaultOptions.retryJitter > 0 ? this.defaultOptions.retryJitter : 0\n- if (url.protocol === 'http') {\n+ if (url.protocol === 'http:') {\nthis.requestApi = http.request\n- } else if (url.protocol === 'https') {\n+ } else if (url.protocol === 'https' || url.protocol === 'https:') {\nthis.requestApi = https.request\n} else {\n- throw new Error('Unsupported URL: ' + connectionOptions.url)\n+ throw new Error(\n+ `Unsupported protocol \"${url.protocol} in URL: \"${connectionOptions.url}\"`\n+ )\n}\n}\n@@ -116,7 +88,7 @@ export class NodeHttpTransport {\nheaders: {[key: string]: string},\nmethod = 'POST',\nbody = '',\n- callbacks?: Partial<CommunicationCallbacks>\n+ callbacks?: Partial<CommunicationObserver>\n): Cancellable {\nconst message = this.createRequestMessage(path, headers, method, body)\nconst cancellable = new CancellableImpl()\n@@ -162,7 +134,7 @@ export class NodeHttpTransport {\nprivate request(\nrequestMessage: {[key: string]: any},\ncancellable: CancellableImpl,\n- callbacks?: Partial<CommunicationCallbacks>\n+ callbacks?: Partial<CommunicationObserver>\n): void {\nconst listeners = this.createRetriableCallbacks(\nrequestMessage,\n@@ -217,8 +189,8 @@ export class NodeHttpTransport {\nprivate createRetriableCallbacks(\nrequestMessage: {[key: string]: any},\ncancellable: CancellableImpl,\n- callbacks: Partial<CommunicationCallbacks> = {}\n- ): CommunicationCallbacks {\n+ callbacks: Partial<CommunicationObserver> = {}\n+ ): CommunicationObserver {\nlet state = 0\nconst retVal = {\nnext: (data: any): void => {\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/client/impl/WriteApiImpl.ts", "diff": "import WriteApi from '../WriteApi'\n-import {WritePrecission, ConnectionOptions} from '..'\n-import {NodeHttpTransport} from './NodeHttpTransport'\n+import {WritePrecission} from '../options'\n+import {Transport} from '../transport'\nexport default class WriteApiImpl implements WriteApi {\n- private transport: NodeHttpTransport\nprivate httpPath: string\nconstructor(\n- connectionOptions: ConnectionOptions,\n+ private transport: Transport,\norg: string,\nbucket: string,\nprecision: WritePrecission\n) {\n- this.transport = new NodeHttpTransport(connectionOptions)\nthis.httpPath = `/write?org=${org}&bucket=${bucket}&precision=${precision}`\n+ // TODO buffer, flush, close\n}\nwriteRecord(record: string): void {\n- this.transport.send(this.httpPath, {}, record)\n+ this.transport.send(this.httpPath, {}, 'POST', record)\n}\nwriteRecords(records: string[]): void {\n- this.transport.send(this.httpPath, {}, records.join('\\n'))\n+ this.transport.send(this.httpPath, {}, 'POST', records.join('\\n'))\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/options.ts", "new_path": "src/client/options.ts", "diff": "+import {Transport} from './transport'\n+\nexport interface ConnectionOptions {\n/** base URL */\nurl: string\n@@ -13,14 +15,26 @@ export interface ConnectionOptions {\ntransportOptions?: {[key: string]: any}\n}\n-// export interface WriteOptions {\n-// /** default tags to add to every write */\n-// defaultTags: {[key: string]: string}\n-// }\n+export interface WriteOptions {\n+ /** max number of records to send in a batch */\n+ batchSize: number\n+ /** flush interval in milliseconds */\n+ flushInterval: number\n+ /** max items to store in the buffer */\n+ bufferLimit: number\n+}\n+export const DEFAULT_WriteOptions: WriteOptions = {\n+ batchSize: 1000,\n+ flushInterval: 1000,\n+ bufferLimit: 1000,\n+}\n-/* eslint-disable @typescript-eslint/no-empty-interface */\n-export interface ClientOptions extends ConnectionOptions {}\n-/* eslint-enabled @typescript-eslint/no-empty-interface */\n+export interface ClientOptions extends ConnectionOptions {\n+ /** to override default writing options */\n+ writeOptions?: WriteOptions\n+ /** to specify custom transport */\n+ transport?: Transport\n+}\nexport const enum WritePrecission {\n/** nanosecond */\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/client/transport.ts", "diff": "+/** Informs about changes in the communication */\n+export interface CommunicationObserver {\n+ /**\n+ * Data chunk received, can be called mupliple times.\n+ */\n+ next(data: any): void\n+ /**\n+ * An error message was received.\n+ */\n+ error(error: Error): void\n+ /**\n+ * Response was fully read.\n+ */\n+ complete(): void\n+}\n+\n+/**\n+ * Cancellation of asynchronous query.\n+ */\n+export interface Cancellable {\n+ /**\n+ * Attempt to cancel execution of this query.\n+ */\n+ cancel(): void\n+\n+ /**\n+ * Is communication canceled.\n+ */\n+ isCancelled(): boolean\n+}\n+\n+export interface Transport {\n+ /**\n+ * Sends data to server and receive communication events via communication callbacks.\n+ *\n+ * @param path HTTP path\n+ * @param headers HTTP headers\n+ * @param method HTTP method\n+ * @param body message body\n+ * @param callbacks communication callbacks\n+ * @return a handle that can cancel the communication\n+ */\n+ send(\n+ path: string,\n+ headers: {[key: string]: string},\n+ method?: string,\n+ body?: string,\n+ callbacks?: Partial<CommunicationObserver>\n+ ): Cancellable\n+}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/influxdb.test.ts", "new_path": "test/unit/influxdb.test.ts", "diff": "@@ -22,11 +22,11 @@ describe('influxdb', () => {\nit('is created from configuration with url and token', () => {\nexpect(\n(new InfluxDB({\n- url: 'http://localhost:9999?token=a',\n+ url: 'https://localhost:9999?token=a',\ntoken: 'b',\n}) as any)._options\n).to.deep.equal({\n- url: 'http://localhost:9999?token=a',\n+ url: 'https://localhost:9999?token=a',\ntoken: 'b',\n})\n})\n@@ -53,5 +53,13 @@ describe('influxdb', () => {\n} as ClientOptions) as ClientOptions)\n).to.throw('No token specified!')\n})\n+ it('fails on unsupported protocol', () => {\n+ expect(\n+ () =>\n+ new InfluxDB(({\n+ url: 'ws://localhost:9999?token=b',\n+ } as ClientOptions) as ClientOptions)\n+ ).to.throw('Unsupported')\n+ })\n})\n})\n" }, { "change_type": "MODIFY", "old_path": "tsconfig.json", "new_path": "tsconfig.json", "diff": "\"esModuleInterop\": true,\n\"sourceMap\": true\n},\n- \"include\": [\"src/**/*.ts\"],\n- \"exclude\": [\"dist\"]\n+ \"include\": [\"src/**/*.ts\", \"test/**/*.ts\"],\n+ \"exclude\": [\"dist\", \"rollup.config.js\"]\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
introduce transport as a communication interface
305,159
04.12.2019 11:18:06
-3,600
fffec06fa32f8df957737d6b056d62caab26425a
initial write API implementation
[ { "change_type": "MODIFY", "old_path": ".vscode/launch.json", "new_path": ".vscode/launch.json", "diff": "\"version\": \"0.2.0\",\n\"configurations\": [\n{\n- \"name\": \"Run Tests\",\n+ \"name\": \"Tests\",\n\"type\": \"node\",\n\"request\": \"launch\",\n\"cwd\": \"${workspaceRoot}\",\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n\"clean\": \"rimraf dist build coverage doc\",\n\"coverage\": \"nyc yarn run test:unit\",\n- \"coverage:open\": \"open coverage/index.html\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n- \"test:unit\": \"mocha --require ts-node/register test/unit/*.test.ts\",\n- \"test:watch\": \"mocha --require ts-node/register test/unit/*.test.ts --watch-extensions ts --watch\",\n+ \"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' test/unit/*.test.ts\",\n+ \"test:watch\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --watch-extensions ts --watch\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n\"lint\": \"eslint 'src/**/*.ts'\",\n\"lint:fix\": \"eslint --fix 'src/**/*.ts'\"\n" }, { "change_type": "MODIFY", "old_path": "src/client/InfluxDB.ts", "new_path": "src/client/InfluxDB.ts", "diff": "@@ -61,6 +61,12 @@ export default class InfluxDB {\nbucket: string,\nprecission: WritePrecission = WritePrecission.ms\n): WriteApi {\n- return new WriteApiImpl(this.transport, org, bucket, precission)\n+ return new WriteApiImpl(\n+ this.transport,\n+ org,\n+ bucket,\n+ precission,\n+ this._options\n+ )\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/errors.ts", "new_path": "src/client/errors.ts", "diff": "@@ -41,7 +41,7 @@ export class HttpError extends Error implements RetriableDecision {\n// try to parse the supplied number as milliseconds\nthis._retryAfter = parseInt(retryAfter)\n} else {\n- this._retryAfter = NaN\n+ this._retryAfter = -1\n}\n}\n@@ -79,6 +79,24 @@ export function canRetryHttpCall(error: any): boolean {\nreturn false\n}\n+/**\n+ * Gets retry delay from the supplied error, possibly using random number up to retryJitter.\n+ */\n+export function getRetryDelay(error: Error, retryJitter: number): number {\n+ if (!error) {\n+ return 0\n+ } else if (typeof (error as any).retryAfter === 'function') {\n+ const delay = ((error as any).retryAfter as () => number)()\n+ if (delay < 0) {\n+ return 1 + Math.round(Math.random() * retryJitter)\n+ } else {\n+ return delay\n+ }\n+ } else {\n+ return 0\n+ }\n+}\n+\nexport class RequestTimedOutError extends Error implements RetriableDecision {\nconstructor() {\nsuper()\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/client/impl/Logger.ts", "diff": "+export interface Logger {\n+ error(message: string, err: any): void\n+ warn(message: string, err: any): void\n+}\n+\n+export const consoleLogger: Logger = Object.freeze({\n+ error(message, error) {\n+ console.error(message, error)\n+ },\n+ warn(message, error) {\n+ console.warn(message, error)\n+ },\n+})\n+let provider: Logger = consoleLogger\n+\n+const instance: Logger = {\n+ error(message, error) {\n+ provider.error(message, error)\n+ },\n+ warn(message, error) {\n+ provider.warn(message, error)\n+ },\n+}\n+\n+export function setLogger(logger: Logger): void {\n+ provider = logger\n+}\n+\n+export default instance\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/client/impl/NodeHttpTransport.ts", "diff": "-import {ConnectionOptions} from '../options'\n+import {ConnectionOptions, DEFAULT_ConnectionOptions} from '../options'\nimport {parse} from 'url'\nimport * as http from 'http'\nimport * as https from 'https'\n@@ -7,15 +7,15 @@ import {\nRequestTimedOutError,\nResponseAbortedError,\ncanRetryHttpCall,\n+ getRetryDelay,\nHttpError,\n} from '../errors'\n-import {Cancellable, CommunicationObserver, Transport} from '../transport'\n-\n-const DEFAULT_OPTIONS: Partial<ConnectionOptions> = {\n- timeout: 10000,\n- maxRetries: 3,\n- retryJitter: 1000,\n-}\n+import {\n+ Cancellable,\n+ CommunicationObserver,\n+ Transport,\n+ SendOptions,\n+} from '../transport'\nclass CancellableImpl implements Cancellable {\nprivate cancelled = false\n@@ -54,9 +54,9 @@ export class NodeHttpTransport implements Transport {\nconstructor(private connectionOptions: ConnectionOptions) {\nconst url = parse(connectionOptions.url)\nthis.defaultOptions = {\n- ...DEFAULT_OPTIONS,\n+ ...DEFAULT_ConnectionOptions,\n...connectionOptions,\n- ...(connectionOptions.transportOptions || {}),\n+ ...connectionOptions.transportOptions,\nport: url.port,\nprotocol: url.protocol,\n}\n@@ -77,20 +77,19 @@ export class NodeHttpTransport implements Transport {\n* Sends data to server and receive communication events via communication callbacks.\n*\n* @param path HTTP path\n+ * @param body message body\n* @param headers HTTP headers\n* @param method HTTP method\n- * @param body message body\n* @param callbacks communication callbacks\n* @return a handle that can cancel the communication\n*/\nsend(\npath: string,\n- headers: {[key: string]: string},\n- method = 'POST',\n- body = '',\n+ body: string,\n+ options: SendOptions,\ncallbacks?: Partial<CommunicationObserver>\n): Cancellable {\n- const message = this.createRequestMessage(path, headers, method, body)\n+ const message = this.createRequestMessage(path, body, options)\nconst cancellable = new CancellableImpl()\nthis.request(message, cancellable, callbacks)\nreturn cancellable\n@@ -108,22 +107,23 @@ export class NodeHttpTransport implements Transport {\n*/\nprivate createRequestMessage(\npath: string,\n- headers: {[key: string]: string},\n- method: string,\n- body: string\n+ body: string,\n+ sendOptions: SendOptions\n): {[key: string]: any} {\nconst bodyBuffer = body ? Buffer.from(body, 'utf-8') : undefined\nconst options: {[key: string]: any} = {\n...this.defaultOptions,\npath,\n- method,\n+ method: sendOptions.method,\nheaders: {\n'content-type': 'text/plain; charset=utf-8',\nauthorization: 'Token ' + this.connectionOptions.token,\n- ...headers,\n+ ...sendOptions.headers,\n},\nbody: bodyBuffer,\n}\n+ if (sendOptions.maxRetries !== undefined)\n+ options.maxRetries = sendOptions.maxRetries\nif (bodyBuffer) {\noptions.headers['content-length'] = bodyBuffer.length\n}\n@@ -202,11 +202,11 @@ export class NodeHttpTransport implements Transport {\nif (state === 0 && canRetryHttpCall(error)) {\nstate = 1\nconst retries = requestMessage.retries || 0\n- if (retries < this.defaultOptions.maxRetries) {\n+ if (retries < requestMessage.maxRetries) {\nrequestMessage.retries = retries + 1\nconst cancelHandle = setTimeout(\n() => this.request(requestMessage, cancellable, callbacks),\n- this.getRetryDelay(error)\n+ getRetryDelay(error, this.retryJitter)\n)\ncancellable.addCancelableAction(() => clearTimeout(cancelHandle))\nreturn\n@@ -223,16 +223,5 @@ export class NodeHttpTransport implements Transport {\n}\nreturn retVal\n}\n-\n- private getRetryDelay(error: Error): number {\n- let delay = -1\n- if (typeof (error as any).retryAfter === 'function') {\n- delay = ((error as any).retryAfter as () => number)()\n- }\n- if (delay < 0) {\n- delay = Math.round(Math.random() * this.retryJitter)\n- }\n- return delay\n- }\n}\nexport default NodeHttpTransport\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/client/impl/WriteApiImpl.ts", "diff": "import WriteApi from '../WriteApi'\n-import {WritePrecission} from '../options'\n+import {\n+ WritePrecission,\n+ DEFAULT_WriteOptions,\n+ ClientOptions,\n+ DEFAULT_ConnectionOptions,\n+} from '../options'\nimport {Transport} from '../transport'\n+import Logger from './Logger'\n+import {getRetryDelay} from '../errors'\n+\n+class WriteBuffer {\n+ length = 0\n+ message?: string = undefined\n+\n+ constructor(\n+ private maxRecords: number,\n+ private flushFn: (message: string) => void\n+ ) {}\n+\n+ add(record: string): void {\n+ if (this.length === 0) {\n+ this.message = record\n+ } else {\n+ this.message = this.message + '\\n' + record\n+ }\n+ this.length++\n+ if (this.length >= this.maxRecords) {\n+ this.flush()\n+ }\n+ }\n+ flush(): void {\n+ if (this.message) {\n+ const message = this.message\n+ this.message = undefined\n+ this.length = 0\n+ this.flushFn(message)\n+ }\n+ }\n+ reset(): string | undefined {\n+ if (this.message) {\n+ const message = this.message\n+ this.message = undefined\n+ this.length = 0\n+ return message\n+ }\n+ return undefined\n+ }\n+}\nexport default class WriteApiImpl implements WriteApi {\n- private httpPath: string\n+ private buffer: WriteBuffer\n+ private closed = false\nconstructor(\n- private transport: Transport,\n+ transport: Transport,\norg: string,\nbucket: string,\n- precision: WritePrecission\n+ precision: WritePrecission,\n+ clientOptions: ClientOptions\n) {\n- this.httpPath = `/write?org=${org}&bucket=${bucket}&precision=${precision}`\n- // TODO buffer, flush, close\n+ const httpPath = `/write?org=${encodeURIComponent(\n+ org\n+ )}&bucket=${encodeURIComponent(bucket)}&precision=${precision}`\n+ const maxRetries =\n+ clientOptions.maxRetries !== undefined\n+ ? clientOptions.maxRetries\n+ : (DEFAULT_ConnectionOptions.maxRetries as number)\n+ const sendOptions = {\n+ method: 'POST',\n+ maxRetries,\n+ }\n+ const writeOptions = {\n+ ...DEFAULT_WriteOptions,\n+ ...clientOptions.writeOptions,\n+ }\n+ const retryJitter =\n+ clientOptions.retryJitter !== undefined\n+ ? clientOptions.retryJitter\n+ : (DEFAULT_ConnectionOptions.retryJitter as number)\n+\n+ const sendBatch = (\n+ message: string | undefined,\n+ retryCountdown: number,\n+ scheduled: boolean\n+ ): void => {\n+ if (message) {\n+ if (!scheduled) scheduleNextSend() // postpone periodic flush\n+ transport.send(httpPath, message, sendOptions, {\n+ error(error: Error): void {\n+ if (retryCountdown > 0) {\n+ Logger.warn(\n+ `Write to influx DB failed, retrying (attempt=${sendOptions.maxRetries -\n+ retryCountdown})`,\n+ error\n+ )\n+ setTimeout(\n+ () => sendBatch(message, retryCountdown - 1, scheduled),\n+ getRetryDelay(error, retryJitter)\n+ )\n+ } else {\n+ Logger.error(\n+ `Write to influx DB failed after ${sendOptions.maxRetries +\n+ 1} attempts`,\n+ error\n+ )\n+ scheduleNextSend() // schedule next periodic flush\n+ }\n+ },\n+ complete(): void {\n+ scheduleNextSend() // schedule next periodic flush\n+ },\n+ })\n+ }\n+ }\n+ this.buffer = new WriteBuffer(writeOptions.batchSize, message => {\n+ sendBatch(message, maxRetries, false)\n+ })\n+ let timeoutHandle: any = undefined\n+ const scheduleNextSend = () => {\n+ if (writeOptions.flushInterval > 0) {\n+ if (timeoutHandle !== undefined) {\n+ clearTimeout(timeoutHandle)\n+ timeoutHandle = undefined\n+ }\n+ if (!this.closed) {\n+ timeoutHandle = setTimeout(\n+ () => sendBatch(this.buffer.reset(), maxRetries, true),\n+ writeOptions.flushInterval\n+ )\n+ }\n+ }\n+ }\n+\n+ scheduleNextSend()\n}\nwriteRecord(record: string): void {\n- this.transport.send(this.httpPath, {}, 'POST', record)\n+ this.buffer.add(record)\n}\nwriteRecords(records: string[]): void {\n- this.transport.send(this.httpPath, {}, 'POST', records.join('\\n'))\n+ for (let i = 0; i < records.length; i++) {\n+ this.buffer.add(records[i])\n+ }\n+ }\n+ flush(): void {\n+ this.buffer.flush()\n+ }\n+ close(): void {\n+ this.closed = true\n+ this.flush()\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/options.ts", "new_path": "src/client/options.ts", "diff": "@@ -7,7 +7,7 @@ export interface ConnectionOptions {\ntoken?: string\n/** socket timeout */\ntimeout?: number\n- /** maximum number of retries for HTTP calls that could succeed when called again */\n+ /** maximum number of retries for repeatable HTTP calls */\nmaxRetries?: number\n/** include random milliseconds when retrying HTTP calls */\nretryJitter?: number\n@@ -15,23 +15,26 @@ export interface ConnectionOptions {\ntransportOptions?: {[key: string]: any}\n}\n+export const DEFAULT_ConnectionOptions: Partial<ConnectionOptions> = {\n+ timeout: 10000,\n+ maxRetries: 3,\n+ retryJitter: 1000,\n+}\n+\nexport interface WriteOptions {\n/** max number of records to send in a batch */\nbatchSize: number\n- /** flush interval in milliseconds */\n+ /** delay between data flushes in milliseconds, at most batch size records are sent during flush */\nflushInterval: number\n- /** max items to store in the buffer */\n- bufferLimit: number\n}\n-export const DEFAULT_WriteOptions: WriteOptions = {\n+export const DEFAULT_WriteOptions: WriteOptions = Object.freeze({\nbatchSize: 1000,\n- flushInterval: 1000,\n- bufferLimit: 1000,\n-}\n+ flushInterval: 60000,\n+})\nexport interface ClientOptions extends ConnectionOptions {\n/** to override default writing options */\n- writeOptions?: WriteOptions\n+ writeOptions?: Partial<WriteOptions>\n/** to specify custom transport */\ntransport?: Transport\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/transport.ts", "new_path": "src/client/transport.ts", "diff": "@@ -5,11 +5,11 @@ export interface CommunicationObserver {\n*/\nnext(data: any): void\n/**\n- * An error message was received.\n+ * Communication ended with an error.\n*/\nerror(error: Error): void\n/**\n- * Response was fully read.\n+ * Communication was successful.\n*/\ncomplete(): void\n}\n@@ -29,6 +29,18 @@ export interface Cancellable {\nisCancelled(): boolean\n}\n+/**\n+ * Options that can be send when sending a message.\n+ */\n+export interface SendOptions {\n+ method: string\n+ maxRetries?: number\n+ headers?: {[key: string]: string}\n+}\n+\n+/**\n+ * Simpified transport layer for communication with influx DB.\n+ */\nexport interface Transport {\n/**\n* Sends data to server and receive communication events via communication callbacks.\n@@ -42,9 +54,8 @@ export interface Transport {\n*/\nsend(\npath: string,\n- headers: {[key: string]: string},\n- method?: string,\n- body?: string,\n+ body: string,\n+ options?: Partial<SendOptions>,\ncallbacks?: Partial<CommunicationObserver>\n): Cancellable\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "import {expect} from 'chai'\nimport {\ncanRetryHttpCall,\n+ getRetryDelay,\nHttpError,\nRequestTimedOutError,\nResponseAbortedError,\n@@ -72,4 +73,31 @@ describe('errors', () => {\n})\n})\n})\n+ describe('retriable delay', () => {\n+ const testSet: any[] = [\n+ {\n+ error: new HttpError(503, 'Service Unavailable', '', '10'),\n+ retryAfter: 10,\n+ },\n+ ,\n+ {error: new RequestTimedOutError(), retryAfter: -1},\n+ {error: new ResponseAbortedError(), retryAfter: -1},\n+ {error: new Error(), retryAfter: 0},\n+ {error: '', retryAfter: 0},\n+ {error: null, retryAfter: 0},\n+ {error: undefined, retryAfter: 0},\n+ ]\n+ testSet.forEach(entry => {\n+ it(`retries ${entry.error} in ${\n+ entry.retryAfter === -1 ? '>=1' : entry.retryAfter\n+ } ms`, () => {\n+ const val = getRetryDelay(entry.error, 1000)\n+ if (entry.retryAfter === -1) {\n+ expect(val).to.be.greaterThan(1)\n+ } else {\n+ expect(val).to.be.equal(entry.retryAfter)\n+ }\n+ })\n+ })\n+ })\n})\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/impl/logger.test.ts", "diff": "+import {expect} from 'chai'\n+import Logger, {setLogger, consoleLogger} from '../../../src/client/impl/Logger'\n+\n+describe('logger', () => {\n+ const testSet = {message: ' hey', error: 'you'}\n+ it(\"uses custom logger's error\", () => {\n+ let args: Array<any> | undefined\n+ setLogger({\n+ error(message, error): void {\n+ args = Array.from(arguments)\n+ consoleLogger.error(message, error)\n+ },\n+ warn(message, error): void {\n+ consoleLogger.warn(message, error)\n+ },\n+ })\n+ Logger.error.call(Logger, testSet.message, testSet.error)\n+ expect(args).to.be.deep.equal([testSet.message, testSet.error])\n+ })\n+ it(\"uses custom logger's warn\", () => {\n+ let args: Array<any> | undefined\n+ setLogger({\n+ error(message, error): void {\n+ consoleLogger.error(message, error)\n+ },\n+ warn(message, error): void {\n+ args = Array.from(arguments)\n+ consoleLogger.warn(message, error)\n+ },\n+ })\n+\n+ Logger.warn.call(Logger, testSet.message, testSet.error)\n+ expect(args).to.be.deep.equal([testSet.message, testSet.error])\n+ })\n+})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
initial write API implementation
305,159
04.12.2019 20:48:23
-3,600
705b1f410aab1d4e6ff42473c37a8a6fe594f08f
add tests for node transport layer
[ { "change_type": "MODIFY", "old_path": ".vscode/launch.json", "new_path": ".vscode/launch.json", "diff": "\"version\": \"0.2.0\",\n\"configurations\": [\n{\n- \"name\": \"Tests\",\n+ \"name\": \"Mocha Tests\",\n\"type\": \"node\",\n\"request\": \"launch\",\n\"cwd\": \"${workspaceRoot}\",\n- \"program\": \"${workspaceRoot}/node_modules/mocha/bin/mocha\",\n+ \"program\": \"${workspaceRoot}/node_modules/mocha/bin/_mocha\",\n\"args\": [\n\"--require\",\n\"ts-node/register\",\n\"--check-leaks\",\n\"--colors\",\n\"${workspaceRoot}/test/**/*.test.ts\"\n- ]\n+ ],\n+ \"internalConsoleOptions\": \"openOnSessionStart\"\n}\n]\n}\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"devDependencies\": {\n\"@types/chai\": \"^4.2.5\",\n\"@types/mocha\": \"^5.2.7\",\n+ \"@types/sinon\": \"^7.5.1\",\n\"@typescript-eslint/eslint-plugin\": \"^2.9.0\",\n\"@typescript-eslint/parser\": \"^2.9.0\",\n\"chai\": \"^4.2.0\",\n\"eslint-config-prettier\": \"^6.7.0\",\n\"eslint-plugin-prettier\": \"^3.1.1\",\n\"mocha\": \"^6.2.2\",\n+ \"nock\": \"^11.7.0\",\n\"nyc\": \"^14.1.1\",\n\"prettier\": \"^1.19.1\",\n\"rimraf\": \"^3.0.0\",\n\"rollup-plugin-sourcemaps\": \"^0.4.2\",\n\"rollup-plugin-terser\": \"^5.1.2\",\n\"rollup-plugin-typescript2\": \"^0.25.2\",\n+ \"sinon\": \"^7.5.0\",\n\"ts-node\": \"^8.5.4\",\n\"typedoc\": \"^0.15.3\",\n\"typescript\": \"^3.7.2\"\n" }, { "change_type": "MODIFY", "old_path": "src/client/errors.ts", "new_path": "src/client/errors.ts", "diff": "@@ -8,7 +8,7 @@ export interface RetriableDecision {\n}\nexport function isStatusCodeRetriable(statusCode: number): boolean {\n- return statusCode == 429 || statusCode == 503\n+ return statusCode === 429 || statusCode === 503\n}\nexport class IllegalArgumentError extends Error {\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/client/impl/NodeHttpTransport.ts", "diff": "@@ -59,12 +59,13 @@ export class NodeHttpTransport implements Transport {\n...connectionOptions.transportOptions,\nport: url.port,\nprotocol: url.protocol,\n+ hostname: url.hostname,\n}\nthis.retryJitter =\nthis.defaultOptions.retryJitter > 0 ? this.defaultOptions.retryJitter : 0\nif (url.protocol === 'http:') {\nthis.requestApi = http.request\n- } else if (url.protocol === 'https' || url.protocol === 'https:') {\n+ } else if (url.protocol === 'https:') {\nthis.requestApi = https.request\n} else {\nthrow new Error(\n@@ -102,7 +103,7 @@ export class NodeHttpTransport implements Transport {\n* @param path API path starting with '/' and containing also query parameters\n* @param headers HTTP headers to use in\n* @param method HTTP method\n- * @param body request body\n+ * @param body request body, will be utf-8 encoded\n* @return configuration suitable for making the request\n*/\nprivate createRequestMessage(\n@@ -110,23 +111,23 @@ export class NodeHttpTransport implements Transport {\nbody: string,\nsendOptions: SendOptions\n): {[key: string]: any} {\n- const bodyBuffer = body ? Buffer.from(body, 'utf-8') : undefined\n+ const bodyBuffer = Buffer.from(body, 'utf-8')\nconst options: {[key: string]: any} = {\n...this.defaultOptions,\npath,\nmethod: sendOptions.method,\nheaders: {\n'content-type': 'text/plain; charset=utf-8',\n- authorization: 'Token ' + this.connectionOptions.token,\n...sendOptions.headers,\n},\nbody: bodyBuffer,\n}\n+ if (this.connectionOptions.token) {\n+ options.headers.authorization = 'Token ' + this.connectionOptions.token\n+ }\nif (sendOptions.maxRetries !== undefined)\noptions.maxRetries = sendOptions.maxRetries\n- if (bodyBuffer) {\noptions.headers['content-length'] = bodyBuffer.length\n- }\nreturn options\n}\n@@ -147,6 +148,8 @@ export class NodeHttpTransport implements Transport {\n}\nconst req = this.requestApi(requestMessage, (res: http.IncomingMessage) => {\nif (cancellable.isCancelled()) {\n+ res.resume()\n+ listeners.complete()\nreturn\n}\nres.on('aborted', () => {\n@@ -156,13 +159,30 @@ export class NodeHttpTransport implements Transport {\nif (statusCode >= 300) {\nlet body = ''\nres.on('data', s => {\n- if (body.length < 2000) body += s.toString()\n+ if (body.length < 2000) {\n+ body += s.toString()\n+ } else {\n+ res.resume()\n+ }\n})\nres.on('end', () =>\n- listeners.error(new HttpError(statusCode, res.statusMessage, body))\n+ listeners.error(\n+ new HttpError(\n+ statusCode,\n+ res.statusMessage,\n+ body,\n+ res.headers['retry-after']\n+ )\n)\n+ )\n+ } else {\n+ res.on('data', data => {\n+ if (cancellable.isCancelled()) {\n+ res.resume()\n} else {\n- res.on('data', listeners.next)\n+ listeners.next(data)\n+ }\n+ })\nres.on('end', listeners.complete)\n}\n})\n@@ -175,8 +195,8 @@ export class NodeHttpTransport implements Transport {\nreq.on('timeout', () => {\nlisteners.error(new RequestTimedOutError())\n})\n- req.on('error', () => {\n- listeners.error(new RequestTimedOutError())\n+ req.on('error', error => {\n+ listeners.error(error)\n})\nreq.on('close', listeners.complete)\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/client/impl/WriteApiImpl.ts", "diff": "@@ -79,6 +79,9 @@ export default class WriteApiImpl implements WriteApi {\n? clientOptions.retryJitter\n: (DEFAULT_ConnectionOptions.retryJitter as number)\n+ /** sendBatch uses scheduleNextSend and vice versa */\n+ // eslint-disable-next-line prefer-const\n+ let scheduleNextSend: () => void\nconst sendBatch = (\nmessage: string | undefined,\nretryCountdown: number,\n@@ -117,7 +120,7 @@ export default class WriteApiImpl implements WriteApi {\nsendBatch(message, maxRetries, false)\n})\nlet timeoutHandle: any = undefined\n- const scheduleNextSend = () => {\n+ scheduleNextSend = (): void => {\nif (writeOptions.flushInterval > 0) {\nif (timeoutHandle !== undefined) {\nclearTimeout(timeoutHandle)\n" }, { "change_type": "RENAME", "old_path": "test/unit/impl/logger.test.ts", "new_path": "test/unit/impl/Logger.test.ts", "diff": "" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "+import {expect} from 'chai'\n+import nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\n+import NodeHttpTransport from '../../../src/client/impl/NodeHttpTransport'\n+import {DEFAULT_ConnectionOptions} from '../../../src/client/options'\n+import * as http from 'http'\n+import * as https from 'https'\n+import sinon from 'sinon'\n+\n+describe('NodeHttpTransport', () => {\n+ describe('constructor', () => {\n+ it('creates the transport from http url', () => {\n+ const transport: any = new NodeHttpTransport({\n+ url: 'http://localhost:9999',\n+ })\n+ expect(transport.defaultOptions).to.deep.equal({\n+ hostname: 'localhost',\n+ maxRetries: 3,\n+ port: '9999',\n+ protocol: 'http:',\n+ retryJitter: 1000,\n+ timeout: 10000,\n+ url: 'http://localhost:9999',\n+ })\n+ expect(transport.requestApi).to.equal(http.request)\n+ expect(transport.retryJitter).to.equal(\n+ DEFAULT_ConnectionOptions.retryJitter\n+ )\n+ })\n+ it('creates the transport from https url', () => {\n+ const transport: any = new NodeHttpTransport({\n+ url: 'https://localhost:9999',\n+ })\n+ expect(transport.defaultOptions).to.deep.equal({\n+ hostname: 'localhost',\n+ maxRetries: 3,\n+ port: '9999',\n+ protocol: 'https:',\n+ retryJitter: 1000,\n+ timeout: 10000,\n+ url: 'https://localhost:9999',\n+ })\n+ expect(transport.requestApi).to.equal(https.request)\n+ })\n+ it('does not create the transport from other uri', () => {\n+ expect(\n+ () =>\n+ new NodeHttpTransport({\n+ url: 'other://localhost:9999',\n+ })\n+ ).to.throw()\n+ })\n+ })\n+ describe('send', () => {\n+ beforeEach(() => {\n+ nock.disableNetConnect()\n+ })\n+ afterEach(() => {\n+ nock.cleanAll()\n+ nock.enableNetConnect()\n+ })\n+ const transportOptions = {\n+ url: 'http://localhost',\n+ timeout: 100,\n+ }\n+ const extraOptions = [\n+ {},\n+ {\n+ token: 'a',\n+ maxRetries: 0,\n+ },\n+ {cancel: true},\n+ {maxRetries: 2, timeout: 10000},\n+ ]\n+ for (let i = 0; i < extraOptions.length; i++) {\n+ const extras = extraOptions[i]\n+ it(`simply works with options ${JSON.stringify(extras)}`, async () => {\n+ const nextFn = sinon.fake()\n+ await new Promise<void>((resolve, reject) => {\n+ const timeout = setTimeout(\n+ () => reject(new Error('timeouted')),\n+ 10000\n+ )\n+ let attempts = 0\n+ const context = nock(transportOptions.url)\n+ .post('/test')\n+ .reply((uri, requestBody) => {\n+ attempts++\n+ if (extras.maxRetries && attempts <= extras.maxRetries) {\n+ console.log(' ... retrying attempt ' + attempts)\n+ return [429, 'yes', {'retry-after': 10}]\n+ } else {\n+ return [200, 'yes']\n+ }\n+ })\n+ .persist()\n+ if (extras.token) {\n+ context.matchHeader('authorization', 'Token ' + extras.token)\n+ }\n+ const cancellable = new NodeHttpTransport({\n+ ...extras,\n+ ...transportOptions,\n+ }).send(\n+ '/test',\n+ '',\n+ {...extras, method: 'POST'},\n+ {\n+ next(data: any) {\n+ nextFn(data)\n+ },\n+ error(error: any) {\n+ clearTimeout(timeout)\n+ reject(new Error('No error expected!'))\n+ },\n+ complete(): void {\n+ clearTimeout(timeout)\n+ resolve()\n+ },\n+ }\n+ )\n+ if (extras.cancel) {\n+ cancellable.cancel()\n+ }\n+ }).then(() => {\n+ expect(nextFn.called)\n+ if (!extras.cancel) {\n+ expect(nextFn.args[0][0].toString()).to.equal('yes')\n+ }\n+ })\n+ // .catch(e => expect.fail(undefined, e, e.toString()))\n+ })\n+ }\n+ })\n+})\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "lodash \"^4.17.13\"\nto-fast-properties \"^2.0.0\"\n+\"@sinonjs/commons@^1\", \"@sinonjs/commons@^1.3.0\", \"@sinonjs/commons@^1.4.0\":\n+ version \"1.6.0\"\n+ resolved \"https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.6.0.tgz#ec7670432ae9c8eb710400d112c201a362d83393\"\n+ dependencies:\n+ type-detect \"4.0.8\"\n+\n+\"@sinonjs/formatio@^3.2.1\":\n+ version \"3.2.2\"\n+ resolved \"https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-3.2.2.tgz#771c60dfa75ea7f2d68e3b94c7e888a78781372c\"\n+ dependencies:\n+ \"@sinonjs/commons\" \"^1\"\n+ \"@sinonjs/samsam\" \"^3.1.0\"\n+\n+\"@sinonjs/samsam@^3.1.0\", \"@sinonjs/samsam@^3.3.3\":\n+ version \"3.3.3\"\n+ resolved \"https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-3.3.3.tgz#46682efd9967b259b81136b9f120fd54585feb4a\"\n+ dependencies:\n+ \"@sinonjs/commons\" \"^1.3.0\"\n+ array-from \"^2.1.1\"\n+ lodash \"^4.17.15\"\n+\n+\"@sinonjs/text-encoding@^0.7.1\":\n+ version \"0.7.1\"\n+ resolved \"https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5\"\n+\n\"@types/chai@^4.2.5\":\nversion \"4.2.5\"\nresolved \"https://registry.yarnpkg.com/@types/chai/-/chai-4.2.5.tgz#f8da153ebbe30babb0adc9a528b9ad32be3175a2\"\ndependencies:\n\"@types/node\" \"*\"\n+\"@types/sinon@^7.5.1\":\n+ version \"7.5.1\"\n+ resolved \"https://registry.yarnpkg.com/@types/sinon/-/sinon-7.5.1.tgz#d27b81af0d1cfe1f9b24eebe7a24f74ae40f5b7c\"\n+\n\"@typescript-eslint/eslint-plugin@^2.9.0\":\nversion \"2.9.0\"\nresolved \"https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.9.0.tgz#fa810282c0e45f6c2310b9c0dfcd25bff97ab7e9\"\n@@ -227,6 +256,10 @@ argparse@^1.0.7:\ndependencies:\nsprintf-js \"~1.0.2\"\n+array-from@^2.1.1:\n+ version \"2.1.1\"\n+ resolved \"https://registry.yarnpkg.com/array-from/-/array-from-2.1.1.tgz#cfe9d8c26628b9dc5aecc62a9f5d8f1f352c1195\"\n+\nasn1.js@^4.0.0:\nversion \"4.10.1\"\nresolved \"https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0\"\n@@ -370,7 +403,7 @@ camelcase@^5.0.0:\nversion \"5.3.1\"\nresolved \"https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320\"\n-chai@^4.2.0:\n+chai@^4.1.2, chai@^4.2.0:\nversion \"4.2.0\"\nresolved \"https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5\"\ndependencies:\n@@ -593,7 +626,7 @@ des.js@^1.0.0:\ninherits \"^2.0.1\"\nminimalistic-assert \"^1.0.0\"\[email protected]:\[email protected], diff@^3.5.0:\nversion \"3.5.0\"\nresolved \"https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12\"\n@@ -1268,12 +1301,20 @@ json-stable-stringify-without-jsonify@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651\"\n+json-stringify-safe@^5.0.1:\n+ version \"5.0.1\"\n+ resolved \"https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb\"\n+\njsonfile@^4.0.0:\nversion \"4.0.0\"\nresolved \"https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb\"\noptionalDependencies:\ngraceful-fs \"^4.1.6\"\n+just-extend@^4.0.2:\n+ version \"4.0.2\"\n+ resolved \"https://registry.yarnpkg.com/just-extend/-/just-extend-4.0.2.tgz#f3f47f7dfca0f989c55410a7ebc8854b07108afc\"\n+\nlevel-blobs@^0.1.7:\nversion \"0.1.7\"\nresolved \"https://registry.yarnpkg.com/level-blobs/-/level-blobs-0.1.7.tgz#9ab9b97bb99f1edbf9f78a3433e21ed56386bdaf\"\n@@ -1397,6 +1438,10 @@ [email protected]:\ndependencies:\nchalk \"^2.0.1\"\n+lolex@^4.1.0, lolex@^4.2.0:\n+ version \"4.2.0\"\n+ resolved \"https://registry.yarnpkg.com/lolex/-/lolex-4.2.0.tgz#ddbd7f6213ca1ea5826901ab1222b65d714b3cd7\"\n+\nlru-cache@^4.0.1:\nversion \"4.1.5\"\nresolved \"https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd\"\n@@ -1552,6 +1597,27 @@ nice-try@^1.0.4:\nversion \"1.0.5\"\nresolved \"https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366\"\n+nise@^1.5.2:\n+ version \"1.5.2\"\n+ resolved \"https://registry.yarnpkg.com/nise/-/nise-1.5.2.tgz#b6d29af10e48b321b307e10e065199338eeb2652\"\n+ dependencies:\n+ \"@sinonjs/formatio\" \"^3.2.1\"\n+ \"@sinonjs/text-encoding\" \"^0.7.1\"\n+ just-extend \"^4.0.2\"\n+ lolex \"^4.1.0\"\n+ path-to-regexp \"^1.7.0\"\n+\n+nock@^11.7.0:\n+ version \"11.7.0\"\n+ resolved \"https://registry.yarnpkg.com/nock/-/nock-11.7.0.tgz#5eaae8b8a55c0dfc014d05692c8cf3d31d61a342\"\n+ dependencies:\n+ chai \"^4.1.2\"\n+ debug \"^4.1.0\"\n+ json-stringify-safe \"^5.0.1\"\n+ lodash \"^4.17.13\"\n+ mkdirp \"^0.5.0\"\n+ propagate \"^2.0.0\"\n+\[email protected]:\nversion \"1.0.5\"\nresolved \"https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.5.tgz#fa930275f5bf5dae188d6192b24b4c8bbac3d76a\"\n@@ -1751,6 +1817,12 @@ path-parse@^1.0.6:\nversion \"1.0.6\"\nresolved \"https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c\"\n+path-to-regexp@^1.7.0:\n+ version \"1.8.0\"\n+ resolved \"https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a\"\n+ dependencies:\n+ isarray \"0.0.1\"\n+\npath-type@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f\"\n@@ -1817,6 +1889,10 @@ progress@^2.0.0, progress@^2.0.3:\nversion \"2.0.3\"\nresolved \"https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8\"\n+propagate@^2.0.0:\n+ version \"2.0.1\"\n+ resolved \"https://registry.yarnpkg.com/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45\"\n+\nprr@~0.0.0:\nversion \"0.0.0\"\nresolved \"https://registry.yarnpkg.com/prr/-/prr-0.0.0.tgz#1a84b85908325501411853d0081ee3fa86e2926a\"\n@@ -2135,6 +2211,18 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:\nversion \"3.0.2\"\nresolved \"https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d\"\n+sinon@^7.5.0:\n+ version \"7.5.0\"\n+ resolved \"https://registry.yarnpkg.com/sinon/-/sinon-7.5.0.tgz#e9488ea466070ea908fd44a3d6478fd4923c67ec\"\n+ dependencies:\n+ \"@sinonjs/commons\" \"^1.4.0\"\n+ \"@sinonjs/formatio\" \"^3.2.1\"\n+ \"@sinonjs/samsam\" \"^3.3.3\"\n+ diff \"^3.5.0\"\n+ lolex \"^4.2.0\"\n+ nise \"^1.5.2\"\n+ supports-color \"^5.5.0\"\n+\nslice-ansi@^2.1.0:\nversion \"2.1.0\"\nresolved \"https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636\"\n@@ -2300,7 +2388,7 @@ [email protected]:\ndependencies:\nhas-flag \"^3.0.0\"\n-supports-color@^5.3.0:\n+supports-color@^5.3.0, supports-color@^5.5.0:\nversion \"5.5.0\"\nresolved \"https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f\"\ndependencies:\n@@ -2382,7 +2470,7 @@ type-check@~0.3.2:\ndependencies:\nprelude-ls \"~1.1.2\"\n-type-detect@^4.0.0, type-detect@^4.0.5:\[email protected], type-detect@^4.0.0, type-detect@^4.0.5:\nversion \"4.0.8\"\nresolved \"https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c\"\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
add tests for node transport layer
305,159
04.12.2019 23:25:35
-3,600
04a76266de9e201e3d0d9e495fdfbc0ba74016ca
enhance testing of node transport with nock
[ { "change_type": "MODIFY", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/client/impl/NodeHttpTransport.ts", "diff": "@@ -89,11 +89,12 @@ export class NodeHttpTransport implements Transport {\nbody: string,\noptions: SendOptions,\ncallbacks?: Partial<CommunicationObserver>\n- ): Cancellable {\n+ ): void {\nconst message = this.createRequestMessage(path, body, options)\nconst cancellable = new CancellableImpl()\n+ if (callbacks && callbacks.useCancellable)\n+ callbacks.useCancellable(cancellable)\nthis.request(message, cancellable, callbacks)\n- return cancellable\n}\n/**\n@@ -159,9 +160,9 @@ export class NodeHttpTransport implements Transport {\nif (statusCode >= 300) {\nlet body = ''\nres.on('data', s => {\n- if (body.length < 2000) {\nbody += s.toString()\n- } else {\n+ if (body.length > 1000) {\n+ body = body.slice(0, 1000)\nres.resume()\n}\n})\n@@ -228,7 +229,10 @@ export class NodeHttpTransport implements Transport {\n() => this.request(requestMessage, cancellable, callbacks),\ngetRetryDelay(error, this.retryJitter)\n)\n- cancellable.addCancelableAction(() => clearTimeout(cancelHandle))\n+ cancellable.addCancelableAction(() => {\n+ if (callbacks.complete) callbacks.complete()\n+ clearTimeout(cancelHandle)\n+ })\nreturn\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/transport.ts", "new_path": "src/client/transport.ts", "diff": "/** Informs about changes in the communication */\n+/**\n+ * Cancellation of asynchronous query.\n+ */\n+export interface Cancellable {\n+ /**\n+ * Attempt to cancel execution of this query.\n+ */\n+ cancel(): void\n+\n+ /**\n+ * Is communication canceled.\n+ */\n+ isCancelled(): boolean\n+}\n+\n+/**\n+ * Let use observe change in the communication.\n+ */\nexport interface CommunicationObserver {\n/**\n* Data chunk received, can be called mupliple times.\n@@ -12,21 +30,10 @@ export interface CommunicationObserver {\n* Communication was successful.\n*/\ncomplete(): void\n-}\n-\n/**\n- * Cancellation of asynchronous query.\n+ * Setups cancelllable for this communication.\n*/\n-export interface Cancellable {\n- /**\n- * Attempt to cancel execution of this query.\n- */\n- cancel(): void\n-\n- /**\n- * Is communication canceled.\n- */\n- isCancelled(): boolean\n+ useCancellable?: (cancellable: Cancellable) => void\n}\n/**\n@@ -50,12 +57,11 @@ export interface Transport {\n* @param method HTTP method\n* @param body message body\n* @param callbacks communication callbacks\n- * @return a handle that can cancel the communication\n*/\nsend(\npath: string,\nbody: string,\noptions?: Partial<SendOptions>,\ncallbacks?: Partial<CommunicationObserver>\n- ): Cancellable\n+ ): void\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "import {expect} from 'chai'\nimport nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\nimport NodeHttpTransport from '../../../src/client/impl/NodeHttpTransport'\n-import {DEFAULT_ConnectionOptions} from '../../../src/client/options'\n+import {\n+ DEFAULT_ConnectionOptions,\n+ ConnectionOptions,\n+} from '../../../src/client/options'\n+import {SendOptions, Cancellable} from '../../../src/client/transport'\nimport * as http from 'http'\nimport * as https from 'https'\nimport sinon from 'sinon'\n+function sendTestData(\n+ connectionOptions: ConnectionOptions,\n+ sendOptions: SendOptions,\n+ setCancellable?: (cancellable: Cancellable) => void\n+): Promise<string> {\n+ return new Promise<string>((resolve, reject) => {\n+ const timeout = setTimeout(() => reject(new Error('timeouted')), 10000)\n+ let data = ''\n+ new NodeHttpTransport(connectionOptions).send('/test', '', sendOptions, {\n+ next(chunk: any) {\n+ data += chunk.toString()\n+ },\n+ error(error: any) {\n+ clearTimeout(timeout)\n+ reject(error)\n+ },\n+ complete(): void {\n+ clearTimeout(timeout)\n+ resolve(data)\n+ },\n+ useCancellable(cancellable: Cancellable) {\n+ if (setCancellable) setCancellable(cancellable)\n+ },\n+ })\n+ })\n+}\n+\ndescribe('NodeHttpTransport', () => {\ndescribe('constructor', () => {\nit('creates the transport from http url', () => {\n@@ -58,6 +89,7 @@ describe('NodeHttpTransport', () => {\nnock.cleanAll()\nnock.enableNetConnect()\n})\n+ describe('positive', () => {\nconst transportOptions = {\nurl: 'http://localhost',\ntimeout: 100,\n@@ -73,7 +105,7 @@ describe('NodeHttpTransport', () => {\n]\nfor (let i = 0; i < extraOptions.length; i++) {\nconst extras = extraOptions[i]\n- it(`simply works with options ${JSON.stringify(extras)}`, async () => {\n+ it(`works with options ${JSON.stringify(extras)}`, async () => {\nconst nextFn = sinon.fake()\nawait new Promise<void>((resolve, reject) => {\nconst timeout = setTimeout(\n@@ -83,7 +115,7 @@ describe('NodeHttpTransport', () => {\nlet attempts = 0\nconst context = nock(transportOptions.url)\n.post('/test')\n- .reply((uri, requestBody) => {\n+ .reply((_uri, _requestBody) => {\nattempts++\nif (extras.maxRetries && attempts <= extras.maxRetries) {\nconsole.log(' ... retrying attempt ' + attempts)\n@@ -96,7 +128,8 @@ describe('NodeHttpTransport', () => {\nif (extras.token) {\ncontext.matchHeader('authorization', 'Token ' + extras.token)\n}\n- const cancellable = new NodeHttpTransport({\n+ let cancellable: any\n+ new NodeHttpTransport({\n...extras,\n...transportOptions,\n}).send(\n@@ -115,6 +148,9 @@ describe('NodeHttpTransport', () => {\nclearTimeout(timeout)\nresolve()\n},\n+ useCancellable(toUse: Cancellable): void {\n+ cancellable = toUse\n+ },\n}\n)\nif (extras.cancel) {\n@@ -130,4 +166,98 @@ describe('NodeHttpTransport', () => {\n})\n}\n})\n+ describe('negative', () => {\n+ const transportOptions = {\n+ url: 'http://localhost',\n+ timeout: 100,\n+ maxRetries: 0,\n+ }\n+ it(`fails on server error`, async () => {\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply(500, 'not ok')\n+ await sendTestData(transportOptions, {method: 'GET'})\n+ .then(() => {\n+ throw new Error('must not succeed')\n+ })\n+ .catch(e => {\n+ expect(e)\n+ .property('statusCode')\n+ .to.equal(500)\n+ })\n+ })\n+ it(`fails on timeout`, async () => {\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .socketDelay(2000)\n+ .reply(200, 'ok')\n+ await sendTestData({...transportOptions, timeout: 100}, {method: 'GET'})\n+ .then(() => {\n+ throw new Error('must not succeed')\n+ })\n+ .catch(e => {\n+ expect(e.toString()).to.include('timed')\n+ })\n+ })\n+ it(`truncates error messages`, async () => {\n+ let bigMessage = 'this is a big error message'\n+ while (bigMessage.length < 1001) bigMessage += bigMessage\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply(500, bigMessage)\n+ await sendTestData(transportOptions, {method: 'GET'})\n+ .then(() => {\n+ throw new Error('must not succeed')\n+ })\n+ .catch((e: any) => {\n+ expect(e)\n+ .property('body')\n+ .to.length(1000)\n+ })\n+ })\n+ it(`is canceled before response arrives`, async () => {\n+ let cancellable: any\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .socketDelay(2000)\n+ .reply((_uri, _requestBody) => {\n+ cancellable.cancel()\n+ return [429, 'yes', {'retry-after': 100}]\n+ })\n+ .persist()\n+ await sendTestData(\n+ {...transportOptions, timeout: 1000, maxRetries: 3},\n+ {method: 'GET'},\n+ toSet => (cancellable = toSet)\n+ )\n+ .then(data => {\n+ expect(data).to.equal('')\n+ })\n+ .catch(e => {\n+ throw e\n+ })\n+ })\n+ it(`is canceled while waiting for retry`, async () => {\n+ let cancellable: any\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply((_uri, _requestBody) => {\n+ setTimeout(() => cancellable.cancel(), 100)\n+ return [429, 'yes', {'retry-after': 100000}]\n+ })\n+ .persist()\n+ await sendTestData(\n+ {...transportOptions, timeout: 10000, maxRetries: 3},\n+ {method: 'GET'},\n+ toSet => (cancellable = toSet)\n+ )\n+ .then(data => {\n+ expect(data).to.equal('')\n+ })\n+ .catch(e => {\n+ throw e\n+ })\n+ })\n+ })\n+ })\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
enhance testing of node transport with nock
305,159
05.12.2019 10:32:38
-3,600
484c520cbce07949ef81ffdf74e690b2f63a0397
finalize node transport test with full coverage
[ { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -9,6 +9,7 @@ import {SendOptions, Cancellable} from '../../../src/client/transport'\nimport * as http from 'http'\nimport * as https from 'https'\nimport sinon from 'sinon'\n+import {Readable} from 'stream'\nfunction sendTestData(\nconnectionOptions: ConnectionOptions,\n@@ -186,7 +187,7 @@ describe('NodeHttpTransport', () => {\n.to.equal(500)\n})\n})\n- it(`fails on timeout`, async () => {\n+ it(`fails on socket timeout`, async () => {\nnock(transportOptions.url)\n.get('/test')\n.socketDelay(2000)\n@@ -199,6 +200,32 @@ describe('NodeHttpTransport', () => {\nexpect(e.toString()).to.include('timed')\n})\n})\n+ it(`fails on connection timeout`, async () => {\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .delayConnection(2000)\n+ .reply(200, 'ok')\n+ await sendTestData({...transportOptions, timeout: 100}, {method: 'GET'})\n+ .then(() => {\n+ throw new Error('must not succeed')\n+ })\n+ .catch(e => {\n+ expect(e.toString()).to.include('timed')\n+ })\n+ })\n+ it(`fails on response timeout`, async () => {\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .delay(2000)\n+ .reply(200, 'ok')\n+ await sendTestData({...transportOptions, timeout: 100}, {method: 'GET'})\n+ .then(() => {\n+ throw new Error('must not succeed')\n+ })\n+ .catch(e => {\n+ expect(e.toString()).to.include('timed')\n+ })\n+ })\nit(`truncates error messages`, async () => {\nlet bigMessage = 'this is a big error message'\nwhile (bigMessage.length < 1001) bigMessage += bigMessage\n@@ -215,7 +242,82 @@ describe('NodeHttpTransport', () => {\n.to.length(1000)\n})\n})\n- it(`is canceled before response arrives`, async () => {\n+ it(`is aborted before the whole response arrives`, async () => {\n+ let remainingChunks = 2\n+ let res: any\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply((_uri, _requestBody) => [\n+ 200,\n+ new Readable({\n+ read() {\n+ remainingChunks--\n+ if (!remainingChunks) {\n+ res.emit('aborted')\n+ }\n+ this.push(remainingChunks < 0 ? null : '.')\n+ },\n+ }),\n+ {\n+ 'X-Whatever': (_req: any, _res: any, _body: any) => {\n+ res = _res\n+ return '1'\n+ },\n+ },\n+ ])\n+ .persist()\n+ await sendTestData(transportOptions, {method: 'GET'})\n+ .then(data => {\n+ expect.fail('not expected!')\n+ })\n+ .catch((e: any) => {\n+ expect(e)\n+ .property('message')\n+ .to.include('aborted')\n+ })\n+ })\n+ it(`signalizes error upon request's error'`, async () => {\n+ let remainingChunks = 2\n+ let req: any\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply((_uri, _requestBody) => [\n+ 200,\n+ new Readable({\n+ read() {\n+ remainingChunks--\n+ if (!remainingChunks) {\n+ req.emit('error', new Error('request failed'))\n+ }\n+ this.push(remainingChunks < 0 ? null : '.')\n+ },\n+ }),\n+ {\n+ 'X-Whatever': (_req: any, _res: any, _body: any) => {\n+ req = _req\n+ return '1'\n+ },\n+ },\n+ ])\n+ .persist()\n+ await sendTestData(transportOptions, {method: 'GET'})\n+ .then(data => {\n+ expect.fail('not expected!')\n+ })\n+ .catch((e: any) => {\n+ expect(e)\n+ .property('message')\n+ .to.include('request failed')\n+ })\n+ })\n+ })\n+ describe('canceled', () => {\n+ const transportOptions = {\n+ url: 'http://localhost',\n+ timeout: 100,\n+ maxRetries: 0,\n+ }\n+ it(`is canceled before the response arrives`, async () => {\nlet cancellable: any\nnock(transportOptions.url)\n.get('/test')\n@@ -242,7 +344,7 @@ describe('NodeHttpTransport', () => {\nnock(transportOptions.url)\n.get('/test')\n.reply((_uri, _requestBody) => {\n- setTimeout(() => cancellable.cancel(), 100)\n+ setTimeout(() => cancellable.cancel(), 50)\nreturn [429, 'yes', {'retry-after': 100000}]\n})\n.persist()\n@@ -258,6 +360,37 @@ describe('NodeHttpTransport', () => {\nthrow e\n})\n})\n+ it(`is canceled after reading the second chunk`, async () => {\n+ let cancellable: any\n+ let remainingChunks = 2\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply(\n+ 200,\n+ (_uri, _requestBody) =>\n+ new Readable({\n+ read() {\n+ remainingChunks--\n+ if (!remainingChunks) {\n+ cancellable.cancel()\n+ }\n+ this.push(remainingChunks < 0 ? null : '.')\n+ },\n+ })\n+ )\n+ .persist()\n+ await sendTestData(\n+ {...transportOptions, timeout: 10000, maxRetries: 3},\n+ {method: 'GET'},\n+ toSet => (cancellable = toSet)\n+ )\n+ .then(data => {\n+ expect(data).to.equal('')\n+ })\n+ .catch(e => {\n+ throw e\n+ })\n+ })\n})\n})\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
finalize node transport test with full coverage
305,159
05.12.2019 20:47:08
-3,600
8d4aad0b26f3c8b7632e980e232e9f049a59be12
wip: write api tests
[ { "change_type": "MODIFY", "old_path": "src/client/WriteApi.ts", "new_path": "src/client/WriteApi.ts", "diff": "*/\nexport default interface WriteApi {\n/**\n- * Write Line Protocol record into specified bucket.\n+ * Write Line Protocol record.\n*\n- * @param record specifies the record in InfluxDB Line Protocol.\n+ * @param record line in InfluxDB Line Protocol.\n*/\nwriteRecord(record: string): void\n/**\n- * Write Line Protocol record into specified bucket.\n+ * Write Line Protocol record.\n*\n- * @param record specifies the record in InfluxDB Line Protocol.\n- * @param precision specifies the precision for the generated timestamp\n- * @param bucket specifies the destination bucket for writes\n- * @param org specifies the destination organization for writes\n+ * @param records lines in InfluxDB Line Protocol\n*/\nwriteRecords(records: Array<string>): void\n+\n+ /**\n+ * Flushes pending writes to the server.\n+ * @return completition promise\n+ */\n+ flush(): Promise<void>\n+\n+ /**\n+ * Closes this writer.\n+ * @return completition promise\n+ */\n+ close(): Promise<void>\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/Logger.ts", "new_path": "src/client/impl/Logger.ts", "diff": "@@ -22,8 +22,10 @@ const instance: Logger = {\n},\n}\n-export function setLogger(logger: Logger): void {\n+export function setLogger(logger: Logger): Logger {\n+ const previous = provider\nprovider = logger\n+ return previous\n}\nexport default instance\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/client/impl/WriteApiImpl.ts", "diff": "@@ -7,7 +7,7 @@ import {\n} from '../options'\nimport {Transport} from '../transport'\nimport Logger from './Logger'\n-import {getRetryDelay} from '../errors'\n+import {getRetryDelay, canRetryHttpCall} from '../errors'\nclass WriteBuffer {\nlength = 0\n@@ -15,12 +15,14 @@ class WriteBuffer {\nconstructor(\nprivate maxRecords: number,\n- private flushFn: (message: string) => void\n+ private flushFn: (message: string) => Promise<void>,\n+ private scheduleSend: () => void\n) {}\nadd(record: string): void {\nif (this.length === 0) {\nthis.message = record\n+ this.scheduleSend()\n} else {\nthis.message = this.message + '\\n' + record\n}\n@@ -29,12 +31,14 @@ class WriteBuffer {\nthis.flush()\n}\n}\n- flush(): void {\n+ flush(): Promise<void> {\nif (this.message) {\nconst message = this.message\nthis.message = undefined\nthis.length = 0\n- this.flushFn(message)\n+ return this.flushFn(message)\n+ } else {\n+ return Promise.resolve()\n}\n}\nreset(): string | undefined {\n@@ -52,6 +56,8 @@ export default class WriteApiImpl implements WriteApi {\nprivate buffer: WriteBuffer\nprivate closed = false\n+ private _timeoutHandle: any = undefined\n+\nconstructor(\ntransport: Transport,\norg: string,\n@@ -68,7 +74,7 @@ export default class WriteApiImpl implements WriteApi {\n: (DEFAULT_ConnectionOptions.maxRetries as number)\nconst sendOptions = {\nmethod: 'POST',\n- maxRetries,\n+ maxRetries: 0, // we control manual retry attempts\n}\nconst writeOptions = {\n...DEFAULT_WriteOptions,\n@@ -80,62 +86,87 @@ export default class WriteApiImpl implements WriteApi {\n: (DEFAULT_ConnectionOptions.retryJitter as number)\n/** sendBatch uses scheduleNextSend and vice versa */\n- // eslint-disable-next-line prefer-const\n- let scheduleNextSend: () => void\n+ // eslint-disable-next-line @typescript-eslint/no-this-alias\n+ const self = this\nconst sendBatch = (\nmessage: string | undefined,\nretryCountdown: number,\nscheduled: boolean\n- ): void => {\n- if (message) {\n- if (!scheduled) scheduleNextSend() // postpone periodic flush\n+ ): Promise<void> => {\n+ if (!this.closed && message) {\n+ return new Promise<void>((resolve, reject) => {\n+ // TODO monitor and limit pending writes\ntransport.send(httpPath, message, sendOptions, {\nerror(error: Error): void {\n- if (retryCountdown > 0) {\n+ if (\n+ !self.closed &&\n+ retryCountdown > 0 &&\n+ canRetryHttpCall(error)\n+ ) {\nLogger.warn(\n- `Write to influx DB failed, retrying (attempt=${sendOptions.maxRetries -\n- retryCountdown})`,\n+ `Write to influx DB failed, retrying (attempt=${maxRetries -\n+ retryCountdown}).`,\nerror\n)\n- setTimeout(\n- () => sendBatch(message, retryCountdown - 1, scheduled),\n+ self._scheduleRetry(\n+ () =>\n+ sendBatch(message, retryCountdown - 1, scheduled)\n+ .then(resolve)\n+ .catch(reject),\ngetRetryDelay(error, retryJitter)\n)\n} else {\nLogger.error(\n- `Write to influx DB failed after ${sendOptions.maxRetries +\n- 1} attempts`,\n+ `Write to influx DB failed after ${maxRetries -\n+ retryCountdown +\n+ 1} attempts.`,\nerror\n)\n- scheduleNextSend() // schedule next periodic flush\n+ reject(error)\n}\n},\ncomplete(): void {\n- scheduleNextSend() // schedule next periodic flush\n+ resolve()\n},\n})\n+ })\n+ } else {\n+ return Promise.resolve()\n}\n}\n- this.buffer = new WriteBuffer(writeOptions.batchSize, message => {\n- sendBatch(message, maxRetries, false)\n- })\n- let timeoutHandle: any = undefined\n- scheduleNextSend = (): void => {\n+ const scheduleNextSend = (): void => {\nif (writeOptions.flushInterval > 0) {\n- if (timeoutHandle !== undefined) {\n- clearTimeout(timeoutHandle)\n- timeoutHandle = undefined\n- }\n+ this._clearFlushTimeout()\nif (!this.closed) {\n- timeoutHandle = setTimeout(\n+ this._timeoutHandle = setTimeout(\n() => sendBatch(this.buffer.reset(), maxRetries, true),\nwriteOptions.flushInterval\n)\n}\n}\n}\n+ this.buffer = new WriteBuffer(\n+ writeOptions.batchSize,\n+ message => {\n+ this._clearFlushTimeout()\n+ return sendBatch(message, maxRetries, false)\n+ },\n+ scheduleNextSend\n+ )\n+ }\n+\n+ private _clearFlushTimeout(): void {\n+ if (this._timeoutHandle !== undefined) {\n+ clearTimeout(this._timeoutHandle)\n+ this._timeoutHandle = undefined\n+ }\n+ }\n- scheduleNextSend()\n+ private _scheduleRetry(fn: () => any, delay: number): void {\n+ if (!this.closed) {\n+ // TODO monitor and limit retries, cancel them on close\n+ setTimeout(fn, delay)\n+ }\n}\nwriteRecord(record: string): void {\n@@ -146,11 +177,12 @@ export default class WriteApiImpl implements WriteApi {\nthis.buffer.add(records[i])\n}\n}\n- flush(): void {\n- this.buffer.flush()\n+ flush(): Promise<void> {\n+ return this.buffer.flush()\n}\n- close(): void {\n+ close(): Promise<void> {\n+ const retVal = this.flush()\nthis.closed = true\n- this.flush()\n+ return retVal\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/options.ts", "new_path": "src/client/options.ts", "diff": "@@ -48,6 +48,4 @@ export const enum WritePrecission {\nms = 'ms',\n/* second */\ns = 's',\n- /** don't send timestamp, let server generate timestamp value */\n- none = '',\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "+import {expect} from 'chai'\n+import nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\n+import NodeHttpTransport from '../../../src/client/impl/NodeHttpTransport'\n+import {ClientOptions, WritePrecission} from '../../../src'\n+import WriteApiImpl from '../../../src/client/impl/WriteApiImpl'\n+import {collectLogging, CollectedLogs} from '../../util'\n+\n+const clientOptions: ClientOptions = {\n+ url: 'http://localhost',\n+ token: 'a',\n+}\n+const transport = new NodeHttpTransport(clientOptions)\n+const ORG = 'org'\n+const BUCKET = 'bucket'\n+const PRECISSION = WritePrecission.s\n+\n+describe('WriteApiImpl', () => {\n+ beforeEach(() => {\n+ nock.disableNetConnect()\n+ })\n+ afterEach(() => {\n+ nock.cleanAll()\n+ nock.enableNetConnect()\n+ })\n+ describe('simple', () => {\n+ let subject: WriteApiImpl\n+ let logs: CollectedLogs\n+ beforeEach(() => {\n+ subject = new WriteApiImpl(\n+ transport,\n+ ORG,\n+ BUCKET,\n+ PRECISSION,\n+ clientOptions\n+ )\n+ logs = collectLogging.before()\n+ })\n+ afterEach(async () => {\n+ subject.close()\n+ collectLogging.after()\n+ })\n+ it('fails on flush without server connection', async () => {\n+ subject.writeRecord('cpu value=10.1')\n+ await subject\n+ .close()\n+ .then(() => expect.fail('failure expected'))\n+ .catch(e => {\n+ expect(logs.error).to.length(1)\n+ expect(e).to.be.ok\n+ })\n+ })\n+ it('can be closed and flushed without any data', async () => {\n+ await subject.close().catch(e => expect.fail('should not happen', e))\n+ await subject.flush().catch(e => expect.fail('should not happen', e))\n+ })\n+ })\n+})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/influxdb.test.ts", "new_path": "test/unit/influxdb.test.ts", "diff": "import {expect} from 'chai'\n-import {InfluxDB, ClientOptions} from '../../src'\n+import {InfluxDB, ClientOptions, WritePrecission} from '../../src'\ndescribe('influxdb', () => {\ndescribe('constructor', () => {\n@@ -62,4 +62,11 @@ describe('influxdb', () => {\n).to.throw('Unsupported')\n})\n})\n+ describe('apis', () => {\n+ const influxDb = new InfluxDB('http://localhost:9999?token=a')\n+ it('writeApi can be obtained without a schedule', () => {\n+ expect(influxDb.getWriteApi('org', 'bucket')).to.be.ok\n+ expect(influxDb.getWriteApi('org', 'bucket', WritePrecission.s)).to.be.ok\n+ })\n+ })\n})\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/util.ts", "diff": "+import {setLogger} from '../src/client/impl/Logger'\n+\n+let previous: any\n+\n+export interface CollectedLogs {\n+ error: Array<Array<any>>\n+ warn: Array<Array<any>>\n+}\n+\n+export const collectLogging = {\n+ before(): CollectedLogs {\n+ const retVal: CollectedLogs = {\n+ error: [],\n+ warn: [],\n+ }\n+ previous = setLogger({\n+ error: function() {\n+ retVal.error.push(Array.from(arguments))\n+ },\n+ warn: function() {\n+ retVal.warn.push(Array.from(arguments))\n+ },\n+ })\n+ return retVal\n+ },\n+ after() {\n+ if (previous) {\n+ setLogger(previous)\n+ previous = undefined\n+ }\n+ },\n+}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
wip: write api tests
305,159
06.12.2019 08:01:35
-3,600
59aa4b62e1f3bcd7b2b266dec622870cbd21e6c8
use non-localhost URL in tests to avoid node defaults
[ { "change_type": "MODIFY", "old_path": "src/client/impl/Logger.ts", "new_path": "src/client/impl/Logger.ts", "diff": "+/**\n+ * Logging interface.\n+ */\nexport interface Logger {\nerror(message: string, err: any): void\nwarn(message: string, err: any): void\n}\n+/**\n+ * Logger that logs to console.out\n+ */\nexport const consoleLogger: Logger = Object.freeze({\nerror(message, error) {\nconsole.error(message, error)\n@@ -22,6 +28,11 @@ const instance: Logger = {\n},\n}\n+/**\n+ * Sets custom logger.\n+ * @param logger new logger\n+ * @return previous logger\n+ */\nexport function setLogger(logger: Logger): Logger {\nconst previous = provider\nprovider = logger\n" }, { "change_type": "MODIFY", "old_path": "src/client/index.ts", "new_path": "src/client/index.ts", "diff": "+/* istanbul ignore next */\nimport InfluxDB from './InfluxDB'\nexport {default as InfluxDB} from './InfluxDB'\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -37,21 +37,22 @@ function sendTestData(\n})\n})\n}\n+const TEST_URL = 'http://test:9999'\ndescribe('NodeHttpTransport', () => {\ndescribe('constructor', () => {\nit('creates the transport from http url', () => {\nconst transport: any = new NodeHttpTransport({\n- url: 'http://localhost:9999',\n+ url: 'http://test:9999',\n})\nexpect(transport.defaultOptions).to.deep.equal({\n- hostname: 'localhost',\n+ hostname: 'test',\nmaxRetries: 3,\nport: '9999',\nprotocol: 'http:',\nretryJitter: 1000,\ntimeout: 10000,\n- url: 'http://localhost:9999',\n+ url: 'http://test:9999',\n})\nexpect(transport.requestApi).to.equal(http.request)\nexpect(transport.retryJitter).to.equal(\n@@ -60,16 +61,16 @@ describe('NodeHttpTransport', () => {\n})\nit('creates the transport from https url', () => {\nconst transport: any = new NodeHttpTransport({\n- url: 'https://localhost:9999',\n+ url: 'https://test:9999',\n})\nexpect(transport.defaultOptions).to.deep.equal({\n- hostname: 'localhost',\n+ hostname: 'test',\nmaxRetries: 3,\nport: '9999',\nprotocol: 'https:',\nretryJitter: 1000,\ntimeout: 10000,\n- url: 'https://localhost:9999',\n+ url: 'https://test:9999',\n})\nexpect(transport.requestApi).to.equal(https.request)\n})\n@@ -77,7 +78,7 @@ describe('NodeHttpTransport', () => {\nexpect(\n() =>\nnew NodeHttpTransport({\n- url: 'other://localhost:9999',\n+ url: 'other://test:9999',\n})\n).to.throw()\n})\n@@ -92,7 +93,7 @@ describe('NodeHttpTransport', () => {\n})\ndescribe('positive', () => {\nconst transportOptions = {\n- url: 'http://localhost',\n+ url: TEST_URL,\ntimeout: 100,\n}\nconst extraOptions = [\n@@ -169,7 +170,7 @@ describe('NodeHttpTransport', () => {\n})\ndescribe('negative', () => {\nconst transportOptions = {\n- url: 'http://localhost',\n+ url: TEST_URL,\ntimeout: 100,\nmaxRetries: 0,\n}\n@@ -313,7 +314,7 @@ describe('NodeHttpTransport', () => {\n})\ndescribe('canceled', () => {\nconst transportOptions = {\n- url: 'http://localhost',\n+ url: TEST_URL,\ntimeout: 100,\nmaxRetries: 0,\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
use non-localhost URL in tests to avoid node defaults
305,159
06.12.2019 08:49:42
-3,600
9c6dfe7f656cade70b02f238d60a7a3b2313010e
introduce max-retries for write operation
[ { "change_type": "MODIFY", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/client/impl/WriteApiImpl.ts", "diff": "@@ -68,18 +68,14 @@ export default class WriteApiImpl implements WriteApi {\nconst httpPath = `/write?org=${encodeURIComponent(\norg\n)}&bucket=${encodeURIComponent(bucket)}&precision=${precision}`\n- const maxRetries =\n- clientOptions.maxRetries !== undefined\n- ? clientOptions.maxRetries\n- : (DEFAULT_ConnectionOptions.maxRetries as number)\n- const sendOptions = {\n- method: 'POST',\n- maxRetries: 0, // we control manual retry attempts\n- }\nconst writeOptions = {\n...DEFAULT_WriteOptions,\n...clientOptions.writeOptions,\n}\n+ const sendOptions = {\n+ method: 'POST',\n+ maxRetries: 0, // we control manual retry attempts\n+ }\nconst retryJitter =\nclientOptions.retryJitter !== undefined\n? clientOptions.retryJitter\n@@ -90,8 +86,7 @@ export default class WriteApiImpl implements WriteApi {\nconst self = this\nconst sendBatch = (\nmessage: string | undefined,\n- retryCountdown: number,\n- scheduled: boolean\n+ retryCountdown: number\n): Promise<void> => {\nif (!this.closed && message) {\nreturn new Promise<void>((resolve, reject) => {\n@@ -104,20 +99,20 @@ export default class WriteApiImpl implements WriteApi {\ncanRetryHttpCall(error)\n) {\nLogger.warn(\n- `Write to influx DB failed, retrying (attempt=${maxRetries -\n+ `Write to influx DB failed, retrying (attempt=${writeOptions.maxRetries -\nretryCountdown}).`,\nerror\n)\nself._scheduleRetry(\n() =>\n- sendBatch(message, retryCountdown - 1, scheduled)\n+ sendBatch(message, retryCountdown - 1)\n.then(resolve)\n.catch(reject),\ngetRetryDelay(error, retryJitter)\n)\n} else {\nLogger.error(\n- `Write to influx DB failed after ${maxRetries -\n+ `Write to influx DB failed after ${writeOptions.maxRetries -\nretryCountdown +\n1} attempts.`,\nerror\n@@ -139,7 +134,7 @@ export default class WriteApiImpl implements WriteApi {\nthis._clearFlushTimeout()\nif (!this.closed) {\nthis._timeoutHandle = setTimeout(\n- () => sendBatch(this.buffer.reset(), maxRetries, true),\n+ () => sendBatch(this.buffer.reset(), writeOptions.maxRetries),\nwriteOptions.flushInterval\n)\n}\n@@ -149,7 +144,7 @@ export default class WriteApiImpl implements WriteApi {\nwriteOptions.batchSize,\nmessage => {\nthis._clearFlushTimeout()\n- return sendBatch(message, maxRetries, false)\n+ return sendBatch(message, writeOptions.maxRetries)\n},\nscheduleNextSend\n)\n" }, { "change_type": "MODIFY", "old_path": "src/client/options.ts", "new_path": "src/client/options.ts", "diff": "@@ -7,7 +7,7 @@ export interface ConnectionOptions {\ntoken?: string\n/** socket timeout */\ntimeout?: number\n- /** maximum number of retries for repeatable HTTP calls */\n+ /** maximum number of retries for HTTP calls that could succeed when retried */\nmaxRetries?: number\n/** include random milliseconds when retrying HTTP calls */\nretryJitter?: number\n@@ -17,7 +17,7 @@ export interface ConnectionOptions {\nexport const DEFAULT_ConnectionOptions: Partial<ConnectionOptions> = {\ntimeout: 10000,\n- maxRetries: 3,\n+ maxRetries: 2,\nretryJitter: 1000,\n}\n@@ -26,10 +26,13 @@ export interface WriteOptions {\nbatchSize: number\n/** delay between data flushes in milliseconds, at most batch size records are sent during flush */\nflushInterval: number\n+ /** max number of retries when write fails */\n+ maxRetries: number\n}\nexport const DEFAULT_WriteOptions: WriteOptions = Object.freeze({\nbatchSize: 1000,\nflushInterval: 60000,\n+ maxRetries: 2,\n})\nexport interface ClientOptions extends ConnectionOptions {\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -47,7 +47,7 @@ describe('NodeHttpTransport', () => {\n})\nexpect(transport.defaultOptions).to.deep.equal({\nhostname: 'test',\n- maxRetries: 3,\n+ maxRetries: DEFAULT_ConnectionOptions.maxRetries,\nport: '9999',\nprotocol: 'http:',\nretryJitter: 1000,\n@@ -65,7 +65,7 @@ describe('NodeHttpTransport', () => {\n})\nexpect(transport.defaultOptions).to.deep.equal({\nhostname: 'test',\n- maxRetries: 3,\n+ maxRetries: DEFAULT_ConnectionOptions.maxRetries,\nport: '9999',\nprotocol: 'https:',\nretryJitter: 1000,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
introduce max-retries for write operation
305,159
06.12.2019 09:10:31
-3,600
8aef3313bea3f9559a301466de12f77890dc751b
retry calls on unknown errors
[ { "change_type": "MODIFY", "old_path": "src/client/errors.ts", "new_path": "src/client/errors.ts", "diff": "@@ -93,7 +93,7 @@ export function getRetryDelay(error: Error, retryJitter: number): number {\nreturn delay\n}\n} else {\n- return 0\n+ return 1 + Math.round(Math.random() * retryJitter)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/client/impl/WriteApiImpl.ts", "diff": "@@ -7,7 +7,7 @@ import {\n} from '../options'\nimport {Transport} from '../transport'\nimport Logger from './Logger'\n-import {getRetryDelay, canRetryHttpCall} from '../errors'\n+import {getRetryDelay, HttpError} from '../errors'\nclass WriteBuffer {\nlength = 0\n@@ -96,7 +96,8 @@ export default class WriteApiImpl implements WriteApi {\nif (\n!self.closed &&\nretryCountdown > 0 &&\n- canRetryHttpCall(error)\n+ (!(error instanceof HttpError) ||\n+ (error as HttpError).statusCode >= 429)\n) {\nLogger.warn(\n`Write to influx DB failed, retrying (attempt=${writeOptions.maxRetries -\n" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "@@ -82,7 +82,7 @@ describe('errors', () => {\n,\n{error: new RequestTimedOutError(), retryAfter: -1},\n{error: new ResponseAbortedError(), retryAfter: -1},\n- {error: new Error(), retryAfter: 0},\n+ {error: new Error(), retryAfter: -1},\n{error: '', retryAfter: 0},\n{error: null, retryAfter: 0},\n{error: undefined, retryAfter: 0},\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
retry calls on unknown errors
305,159
06.12.2019 13:16:34
-3,600
93c52313ffc1c16e02e67b377c18ee08d8bf5f13
finalize test for write API essentials
[ { "change_type": "MODIFY", "old_path": "src/client/WriteApi.ts", "new_path": "src/client/WriteApi.ts", "diff": "@@ -30,4 +30,10 @@ export default interface WriteApi {\n* @return completition promise\n*/\nclose(): Promise<void>\n+\n+ /**\n+ * Unlike close, dispose simply quits without trying to send\n+ * the buffered data.\n+ */\n+ dispose(): void\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/Logger.ts", "new_path": "src/client/impl/Logger.ts", "diff": "@@ -11,10 +11,10 @@ export interface Logger {\n*/\nexport const consoleLogger: Logger = Object.freeze({\nerror(message, error) {\n- console.error(message, error)\n+ console.error('ERROR: ' + message, error)\n},\nwarn(message, error) {\n- console.warn(message, error)\n+ console.warn('WARN: ' + message, error)\n},\n})\nlet provider: Logger = consoleLogger\n" }, { "change_type": "MODIFY", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/client/impl/WriteApiImpl.ts", "diff": "@@ -5,7 +5,7 @@ import {\nClientOptions,\nDEFAULT_ConnectionOptions,\n} from '../options'\n-import {Transport} from '../transport'\n+import {Transport, SendOptions} from '../transport'\nimport Logger from './Logger'\nimport {getRetryDelay, HttpError} from '../errors'\n@@ -28,7 +28,9 @@ class WriteBuffer {\n}\nthis.length++\nif (this.length >= this.maxRecords) {\n- this.flush()\n+ this.flush().catch(e => {\n+ // an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n+ })\n}\n}\nflush(): Promise<void> {\n@@ -42,13 +44,12 @@ class WriteBuffer {\n}\n}\nreset(): string | undefined {\n- if (this.message) {\nconst message = this.message\n+ if (message) {\nthis.message = undefined\nthis.length = 0\n- return message\n}\n- return undefined\n+ return message\n}\n}\n@@ -67,14 +68,17 @@ export default class WriteApiImpl implements WriteApi {\n) {\nconst httpPath = `/write?org=${encodeURIComponent(\norg\n- )}&bucket=${encodeURIComponent(bucket)}&precision=${precision}`\n+ )}&bucket=${encodeURIComponent(bucket)}&precission=${precision}`\nconst writeOptions = {\n...DEFAULT_WriteOptions,\n...clientOptions.writeOptions,\n}\n- const sendOptions = {\n+ const sendOptions: Partial<SendOptions> = {\nmethod: 'POST',\nmaxRetries: 0, // we control manual retry attempts\n+ headers: {\n+ 'content-type': 'text/plain; charset=utf-8',\n+ },\n}\nconst retryJitter =\nclientOptions.retryJitter !== undefined\n@@ -100,8 +104,7 @@ export default class WriteApiImpl implements WriteApi {\n(error as HttpError).statusCode >= 429)\n) {\nLogger.warn(\n- `Write to influx DB failed, retrying (attempt=${writeOptions.maxRetries -\n- retryCountdown}).`,\n+ `Write to influx DB failed (remaining attempts: ${retryCountdown}).`,\nerror\n)\nself._scheduleRetry(\n@@ -112,12 +115,7 @@ export default class WriteApiImpl implements WriteApi {\ngetRetryDelay(error, retryJitter)\n)\n} else {\n- Logger.error(\n- `Write to influx DB failed after ${writeOptions.maxRetries -\n- retryCountdown +\n- 1} attempts.`,\n- error\n- )\n+ Logger.error(`Write to influx DB failed.`, error)\nreject(error)\n}\n},\n@@ -135,7 +133,12 @@ export default class WriteApiImpl implements WriteApi {\nthis._clearFlushTimeout()\nif (!this.closed) {\nthis._timeoutHandle = setTimeout(\n- () => sendBatch(this.buffer.reset(), writeOptions.maxRetries),\n+ () =>\n+ sendBatch(this.buffer.reset(), writeOptions.maxRetries).catch(\n+ e => {\n+ // an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n+ }\n+ ),\nwriteOptions.flushInterval\n)\n}\n@@ -181,4 +184,8 @@ export default class WriteApiImpl implements WriteApi {\nthis.closed = true\nreturn retVal\n}\n+ dispose(): void {\n+ this._clearFlushTimeout()\n+ this.closed = true\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "src/client/index.ts", "new_path": "src/client/index.ts", "diff": "/* istanbul ignore next */\n-import InfluxDB from './InfluxDB'\n-\n-export {default as InfluxDB} from './InfluxDB'\nexport * from './options'\nexport * from './errors'\nexport {default as WriteApi} from './WriteApi'\n-export default InfluxDB\n+export {default as InfluxDB, default} from './InfluxDB'\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "import {expect} from 'chai'\nimport nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\nimport NodeHttpTransport from '../../../src/client/impl/NodeHttpTransport'\n-import {ClientOptions, WritePrecission} from '../../../src'\n+import {\n+ ClientOptions,\n+ WritePrecission,\n+ DEFAULT_WriteOptions,\n+ WriteOptions,\n+} from '../../../src'\nimport WriteApiImpl from '../../../src/client/impl/WriteApiImpl'\nimport {collectLogging, CollectedLogs} from '../../util'\nconst clientOptions: ClientOptions = {\n- url: 'http://localhost',\n+ url: 'http://fake:9999',\ntoken: 'a',\n+ retryJitter: 0, // minimum delay for tests\n}\nconst transport = new NodeHttpTransport(clientOptions)\nconst ORG = 'org'\nconst BUCKET = 'bucket'\nconst PRECISSION = WritePrecission.s\n+const WRITE_PATH = `/write?org=${ORG}&bucket=${BUCKET}&precission=${PRECISSION}`\n+\ndescribe('WriteApiImpl', () => {\nbeforeEach(() => {\nnock.disableNetConnect()\n@@ -33,13 +41,18 @@ describe('WriteApiImpl', () => {\nPRECISSION,\nclientOptions\n)\n- logs = collectLogging.before()\n+ // logs = collectLogging.decorate()\n+ logs = collectLogging.replace()\n})\nafterEach(async () => {\nsubject.close()\ncollectLogging.after()\n})\n- it('fails on flush without server connection', async () => {\n+ it('can be closed and flushed without any data', async () => {\n+ await subject.close().catch(e => expect.fail('should not happen', e))\n+ await subject.flush().catch(e => expect.fail('should not happen', e))\n+ })\n+ it('fails on close without server connection', async () => {\nsubject.writeRecord('test value=1')\nsubject.writeRecords(['test value=2', 'test value=3'])\nawait subject\n@@ -50,9 +63,132 @@ describe('WriteApiImpl', () => {\nexpect(e).to.be.ok\n})\n})\n- it('can be closed and flushed without any data', async () => {\n- await subject.close().catch(e => expect.fail('should not happen', e))\n- await subject.flush().catch(e => expect.fail('should not happen', e))\n+ it('fails on flush without server connection', async () => {\n+ subject.writeRecord('test value=1')\n+ subject.writeRecords(['test value=2', 'test value=3'])\n+ await subject\n+ .flush()\n+ .then(() => expect.fail('failure expected'))\n+ .catch(e => {\n+ expect(logs.error).to.length(1)\n+ expect(logs.warn).to.length(DEFAULT_WriteOptions.maxRetries)\n+ expect(e).to.be.ok\n+ })\n+ })\n+ })\n+ describe('configuration', () => {\n+ let subject: WriteApiImpl\n+ let logs: CollectedLogs\n+ function useSubject(writeOptions: Partial<WriteOptions>): void {\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISSION, {\n+ ...clientOptions,\n+ writeOptions,\n+ })\n+ }\n+ beforeEach(() => {\n+ // logs = collectLogging.decorate()\n+ logs = collectLogging.replace()\n+ })\n+ afterEach(async () => {\n+ subject.close()\n+ collectLogging.after()\n+ })\n+ it('flushes the response in specified batchSize', async () => {\n+ useSubject({flushInterval: 0, batchSize: 1})\n+ subject.writeRecord('test value=1')\n+ subject.writeRecords(['test value=2', 'test value=3'])\n+ // wait for http calls to finish\n+ await new Promise(resolve => setTimeout(resolve, 10))\n+ await subject.close().then(() => {\n+ expect(logs.error).to.length(3)\n+ expect(logs.warn).to.length(3 * DEFAULT_WriteOptions.maxRetries)\n+ })\n+ })\n+ it('does not retry write when configured to do so', async () => {\n+ useSubject({maxRetries: 0, batchSize: 1})\n+ subject.writeRecord('test value=1')\n+ await subject.close().then(() => {\n+ expect(logs.error).to.length(1)\n+ expect(logs.warn).to.length(0)\n+ })\n+ })\n+ it('uses the pre-configured batchSize', async () => {\n+ useSubject({flushInterval: 0, maxRetries: 0, batchSize: 2})\n+ subject.writeRecords(['test value=1', 'test value=2', 'test value=3'])\n+ await new Promise(resolve => setTimeout(resolve, 10)) // wait for HTTP to finish\n+ subject.dispose()\n+ expect(logs.error).to.length(1)\n+ expect(logs.warn).to.length(0)\n+ })\n+ })\n+ describe('flush on background', () => {\n+ let subject: WriteApiImpl\n+ let logs: CollectedLogs\n+ function useSubject(writeOptions: Partial<WriteOptions>): void {\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISSION, {\n+ ...clientOptions,\n+ writeOptions,\n+ })\n+ }\n+ beforeEach(() => {\n+ // logs = collectLogging.decorate()\n+ logs = collectLogging.replace()\n+ })\n+ afterEach(async () => {\n+ subject.close()\n+ collectLogging.after()\n+ })\n+ it('flushes the response automatically', async () => {\n+ useSubject({flushInterval: 5, maxRetries: 0, batchSize: 10})\n+ subject.writeRecord('test value=1')\n+ await new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\n+ expect(logs.error).to.length(1)\n+ subject.writeRecord('test value=2')\n+ await new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\n+ expect(logs.error).to.length(2)\n+ await new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush\n+ await subject.flush().then(() => {\n+ expect(logs.error).to.length(2)\n+ })\n+ })\n+ })\n+ describe('usage of server API', () => {\n+ let subject: WriteApiImpl\n+ let logs: CollectedLogs\n+ function useSubject(writeOptions: Partial<WriteOptions>): void {\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISSION, {\n+ ...clientOptions,\n+ writeOptions,\n+ })\n+ }\n+ beforeEach(() => {\n+ logs = collectLogging.decorate()\n+ // logs = collectLogging.replace()\n+ })\n+ afterEach(async () => {\n+ subject.close()\n+ collectLogging.after()\n+ })\n+ it('flushes the response without errors', async () => {\n+ useSubject({flushInterval: 5, maxRetries: 1, batchSize: 10})\n+ let requests = 0\n+ nock(clientOptions.url)\n+ .post(WRITE_PATH)\n+ .reply((_uri, _requestBody) => {\n+ requests++\n+ return [requests % 2 ? 429 : 200, 'yes', {'retry-after': '1'}]\n+ })\n+ .persist()\n+ subject.writeRecord('test value=1')\n+ await new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\n+ expect(logs.error).to.length(0)\n+ subject.writeRecord('test value=2')\n+ await new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\n+ expect(logs.error).to.length(0)\n+ await new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush\n+ await subject.flush().then(() => {\n+ expect(logs.error).to.length(0)\n+ })\n})\n})\n})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/influxdb.test.ts", "new_path": "test/unit/influxdb.test.ts", "diff": "@@ -64,7 +64,7 @@ describe('influxdb', () => {\n})\ndescribe('apis', () => {\nconst influxDb = new InfluxDB('http://localhost:9999?token=a')\n- it('writeApi can be obtained without a schedule', () => {\n+ it('writeApi can be obtained without a pending schedule', () => {\nexpect(influxDb.getWriteApi('org', 'bucket')).to.be.ok\nexpect(influxDb.getWriteApi('org', 'bucket', WritePrecission.s)).to.be.ok\n})\n" }, { "change_type": "MODIFY", "old_path": "test/util.ts", "new_path": "test/util.ts", "diff": "@@ -8,7 +8,7 @@ export interface CollectedLogs {\n}\nexport const collectLogging = {\n- before(): CollectedLogs {\n+ replace(): CollectedLogs {\nconst retVal: CollectedLogs = {\nerror: [],\nwarn: [],\n@@ -23,6 +23,23 @@ export const collectLogging = {\n})\nreturn retVal\n},\n+ decorate(): CollectedLogs {\n+ const retVal: CollectedLogs = {\n+ error: [],\n+ warn: [],\n+ }\n+ const previous = setLogger({\n+ error: function() {\n+ ;(previous.error as any).apply(previous, Array.from(arguments))\n+ retVal.error.push(Array.from(arguments))\n+ },\n+ warn: function() {\n+ ;(previous.warn as any).apply(previous, Array.from(arguments))\n+ retVal.warn.push(Array.from(arguments))\n+ },\n+ })\n+ return retVal\n+ },\nafter() {\nif (previous) {\nsetLogger(previous)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
finalize test for write API essentials
305,159
06.12.2019 15:13:28
-3,600
ecf92e0bbabb02bb5191008e3b09a3972c916ab4
defactor the code, remove client directory
[ { "change_type": "RENAME", "old_path": "src/client/InfluxDB.ts", "new_path": "src/InfluxDB.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "src/client/WriteApi.ts", "new_path": "src/WriteApi.ts", "diff": "" }, { "change_type": "DELETE", "old_path": "src/client/index.ts", "new_path": null, "diff": "-/* istanbul ignore next */\n-export * from './options'\n-export * from './errors'\n-export {default as WriteApi} from './WriteApi'\n-export {default as InfluxDB, default} from './InfluxDB'\n" }, { "change_type": "RENAME", "old_path": "src/client/errors.ts", "new_path": "src/errors.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "src/client/impl/Logger.ts", "new_path": "src/impl/Logger.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "src/client/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "src/client/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "" }, { "change_type": "MODIFY", "old_path": "src/index.ts", "new_path": "src/index.ts", "diff": "-export * from './client'\n+export * from './options'\n+export * from './errors'\n+export {default as WriteApi} from './WriteApi'\n+export {default as InfluxDB} from './InfluxDB'\n" }, { "change_type": "RENAME", "old_path": "src/client/options.ts", "new_path": "src/options.ts", "diff": "" }, { "change_type": "RENAME", "old_path": "src/client/transport.ts", "new_path": "src/transport.ts", "diff": "" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "@@ -7,7 +7,7 @@ import {\nResponseAbortedError,\nIllegalArgumentError,\nRetriableDecision,\n-} from '../../src/client/errors'\n+} from '../../src/errors'\ndescribe('errors', () => {\ndescribe('retriable errors', () => {\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/Logger.test.ts", "new_path": "test/unit/impl/Logger.test.ts", "diff": "import {expect} from 'chai'\n-import Logger, {setLogger, consoleLogger} from '../../../src/client/impl/Logger'\n+import Logger, {setLogger, consoleLogger} from '../../../src/impl/Logger'\ndescribe('logger', () => {\nconst testSet = {message: ' hey', error: 'you'}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "import {expect} from 'chai'\nimport nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\n-import NodeHttpTransport from '../../../src/client/impl/NodeHttpTransport'\n+import NodeHttpTransport from '../../../src/impl/NodeHttpTransport'\nimport {\nDEFAULT_ConnectionOptions,\nConnectionOptions,\n-} from '../../../src/client/options'\n-import {SendOptions, Cancellable} from '../../../src/client/transport'\n+} from '../../../src/options'\n+import {SendOptions, Cancellable} from '../../../src/transport'\nimport * as http from 'http'\nimport * as https from 'https'\nimport sinon from 'sinon'\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "import {expect} from 'chai'\nimport nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\n-import NodeHttpTransport from '../../../src/client/impl/NodeHttpTransport'\n+import NodeHttpTransport from '../../../src/impl/NodeHttpTransport'\nimport {\nClientOptions,\nWritePrecission,\nDEFAULT_WriteOptions,\nWriteOptions,\n} from '../../../src'\n-import WriteApiImpl from '../../../src/client/impl/WriteApiImpl'\n+import WriteApiImpl from '../../../src/impl/WriteApiImpl'\nimport {collectLogging, CollectedLogs} from '../../util'\nconst clientOptions: ClientOptions = {\n" }, { "change_type": "MODIFY", "old_path": "test/util.ts", "new_path": "test/util.ts", "diff": "-import {setLogger} from '../src/client/impl/Logger'\n+import {setLogger} from '../src/impl/Logger'\nlet previous: any\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
defactor the code, remove client directory
305,159
06.12.2019 22:12:05
-3,600
001fc9acbe4aed1fa21b42a64cec7c17cd8bae5c
wip: add Point to represent measurement
[ { "change_type": "ADD", "old_path": null, "new_path": "src/Point.ts", "diff": "+/**\n+ * Point defines the values that will be written to the database.\n+ * <a href=\"http://bit.ly/influxdata-point\">See Go Implementation</a>.\n+ */\n+export default class Point {\n+ private name: string\n+ private tags: {[key: string]: string} = {}\n+ private fields: {[key: string]: string} = {}\n+ private time: string\n+\n+ /**\n+ * Create a new Point with specified a measurement name.\n+ *\n+ * @param measurementName the measurement name\n+ * @return new instance of {@link Point}\n+ */\n+ constructor(measurementName?: string) {\n+ if (measurementName) this.name = measurementName\n+ }\n+\n+ /**\n+ * Setups point's measurement.\n+ *\n+ * @param name the measurement name\n+ * @return new instance of {@link Point}\n+ */\n+ public setMeasurement(name: string): Point {\n+ this.name = name\n+ return this\n+ }\n+\n+ /**\n+ * Adds a tag.\n+ *\n+ * @param name tag name\n+ * @param value tag value\n+ * @return this\n+ */\n+ public addTag(name: string, value: string): Point {\n+ this.tags[name] = value\n+ return this\n+ }\n+\n+ /**\n+ * Adds a boolean field.\n+ *\n+ * @param field field name\n+ * @param value field value\n+ * @return this\n+ */\n+ public addBooleanField(name: string, value: boolean | any): Point {\n+ this.fields[name] = !!value ? 'T' : 'F'\n+ return this\n+ }\n+\n+ /**\n+ * Adds an integer field.\n+ *\n+ * @param name field name\n+ * @param value field value\n+ * @return this\n+ */\n+ public addIntegerField(name: string, value: number | any): Point {\n+ if (typeof value !== 'number') {\n+ value = String(value)\n+ if (isNaN((value = parseInt(value)))) {\n+ throw new Error(\n+ `Expected integer value for field ${name}, but got '${value}'!`\n+ )\n+ }\n+ }\n+ // count with conversion to number\n+ this.fields[name] = `${Math.floor(value as number)}i`\n+ return this\n+ }\n+ // TODO addNumberField\n+ // TODO addStringField\n+ // TODO set time field\n+ // TODO define toLineProtocol and toString\n+ public toLineProtocol(/* optional PointSettings */): string {\n+ // TODO real implementation\n+ return `${this.name},${this.tags} ${this.fields} ${this.time}`\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/index.ts", "new_path": "src/index.ts", "diff": "export * from './options'\nexport * from './errors'\n+export {default as Point} from './Point'\nexport {default as WriteApi} from './WriteApi'\nexport {default as InfluxDB} from './InfluxDB'\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -162,8 +162,8 @@ describe('WriteApiImpl', () => {\n})\n}\nbeforeEach(() => {\n- logs = collectLogging.decorate()\n- // logs = collectLogging.replace()\n+ // logs = collectLogging.decorate()\n+ logs = collectLogging.replace()\n})\nafterEach(async () => {\nsubject.close()\n@@ -182,10 +182,14 @@ describe('WriteApiImpl', () => {\nsubject.writeRecord('test value=1')\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\nexpect(logs.error).to.length(0)\n+ expect(logs.warn).to.length(1)\nsubject.writeRecord('test value=2')\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\nexpect(logs.error).to.length(0)\n+ expect(logs.warn).to.length(2)\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush\n+ expect(logs.error).to.length(0)\n+ expect(logs.warn).to.length(2)\nawait subject.flush().then(() => {\nexpect(logs.error).to.length(0)\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
wip: add Point to represent measurement
305,159
08.12.2019 20:15:21
-3,600
7c353377b0f28e2e4856ed9fccfd2ab2aa2bbd6d
add point implementation with tests
[ { "change_type": "MODIFY", "old_path": "src/Point.ts", "new_path": "src/Point.ts", "diff": "+import {escape} from './grammar/escape'\n+import {PointSettings} from './options'\n/**\n* Point defines the values that will be written to the database.\n* <a href=\"http://bit.ly/influxdata-point\">See Go Implementation</a>.\n@@ -6,7 +8,7 @@ export default class Point {\nprivate name: string\nprivate tags: {[key: string]: string} = {}\nprivate fields: {[key: string]: string} = {}\n- private time: string\n+ private time: number | string | undefined\n/**\n* Create a new Point with specified a measurement name.\n@@ -24,7 +26,7 @@ export default class Point {\n* @param name the measurement name\n* @return new instance of {@link Point}\n*/\n- public setMeasurement(name: string): Point {\n+ public measurement(name: string): Point {\nthis.name = name\nreturn this\n}\n@@ -62,23 +64,89 @@ export default class Point {\n*/\npublic addIntegerField(name: string, value: number | any): Point {\nif (typeof value !== 'number') {\n- value = String(value)\n- if (isNaN((value = parseInt(value)))) {\n+ let val: number\n+ if (isNaN((val = parseInt(String(value))))) {\nthrow new Error(\n`Expected integer value for field ${name}, but got '${value}'!`\n)\n}\n+ value = val\n}\n- // count with conversion to number\nthis.fields[name] = `${Math.floor(value as number)}i`\nreturn this\n}\n- // TODO addNumberField\n- // TODO addStringField\n- // TODO set time field\n- // TODO define toLineProtocol and toString\n- public toLineProtocol(/* optional PointSettings */): string {\n- // TODO real implementation\n- return `${this.name},${this.tags} ${this.fields} ${this.time}`\n+\n+ /**\n+ * Adds a number field.\n+ *\n+ * @param name field name\n+ * @param value field value\n+ * @return this\n+ */\n+ public addNumberField(name: string, value: number | any): Point {\n+ if (typeof value !== 'number') {\n+ let val: number\n+ if (isNaN((val = parseFloat(value)))) {\n+ throw new Error(\n+ `Expected float value for field ${name}, but got '${value}'!`\n+ )\n+ }\n+ value = val\n+ }\n+ this.fields[name] = String(value)\n+ return this\n+ }\n+\n+ public addStringField(name: string, value: string | any): Point {\n+ if (value !== null && value !== undefined) {\n+ if (typeof value !== 'string') value = String(value)\n+ this.fields[name] = escape.quoted(value)\n+ }\n+ return this\n+ }\n+\n+ public setTime(value: number | string | undefined): Point {\n+ this.time = value\n+ return this\n+ }\n+\n+ public toLineProtocol(settings?: PointSettings): string | undefined {\n+ if (!this.name) return undefined\n+ let fieldsLine = ''\n+ Object.keys(this.fields)\n+ .sort()\n+ .forEach(x => {\n+ if (x) {\n+ const val = this.fields[x]\n+ if (fieldsLine.length > 0) fieldsLine += ','\n+ fieldsLine += `${escape.tag(x)}=${val}`\n+ }\n+ })\n+ if (fieldsLine.length === 0) return undefined // no fields present\n+ let tagsLine = ''\n+ const tags = settings ? {...settings.defaultTags, ...this.tags} : this.tags\n+ Object.keys(tags)\n+ .sort()\n+ .forEach(x => {\n+ if (x) {\n+ const val = tags[x]\n+ if (val) {\n+ tagsLine += ','\n+ tagsLine += `${escape.tag(x)}=${escape.tag(val)}`\n+ }\n+ }\n+ })\n+ let time = this.time\n+ if (settings && settings.convertTime) {\n+ time = settings.convertTime(time)\n+ }\n+\n+ return `${escape.measurement(this.name)}${tagsLine} ${fieldsLine}${\n+ time !== undefined ? ' ' + time : ''\n+ }`\n+ }\n+ toString(): string {\n+ const line = this.toLineProtocol(undefined)\n+ return line ? line : `invalid point: ${JSON.stringify(this, undefined)}`\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/options.ts", "new_path": "src/options.ts", "diff": "@@ -52,3 +52,8 @@ export const enum WritePrecission {\n/* second */\ns = 's',\n}\n+\n+export interface PointSettings {\n+ defaultTags: {[key: string]: string}\n+ convertTime?: (value: undefined | string | number) => string | undefined\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/fixture/escapeTables.json", "diff": "+{\n+ \"tag\": [\n+ [\"ab\", \"ab\"],\n+ [\"a\\\\b\", \"a\\\\b\"],\n+ [\"a\\\\\\\\b\", \"a\\\\\\\\b\"],\n+ [\"a,\", \"a\\\\,\"],\n+ [\"a,b\", \"a\\\\,b\"],\n+ [\"a=b\", \"a\\\\=b\"],\n+ [\"a b\", \"a\\\\ b\"],\n+ [\"a b=c\", \"a\\\\ b\\\\=c\"],\n+ [\"'a' \\\\b=c\\\\,\\\\\\\\\\\"d\\\"\", \"'a'\\\\ \\\\b\\\\=c\\\\\\\\,\\\\\\\\\\\"d\\\"\"]\n+ ],\n+ \"measurement\": [\n+ [\"ab\", \"ab\"],\n+ [\"a,\", \"a\\\\,\"],\n+ [\"a,b\", \"a\\\\,b\"],\n+ [\"a b\", \"a\\\\ b\"],\n+ [\"a b,c\", \"a\\\\ b\\\\,c\"]\n+ ],\n+ \"quoted\": [\n+ [\"ab\", \"\\\"ab\\\"\"],\n+ [\"a\\\"\", \"\\\"a\\\\\\\"\\\"\"],\n+ [\"a\\\"b\", \"\\\"a\\\\\\\"b\\\"\"],\n+ [\"a\\\"b\\\"c\", \"\\\"a\\\\\\\"b\\\\\\\"c\\\"\"]\n+ ]\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/fixture/pointTables.json", "diff": "+[\n+ {\n+ \"fails\": true\n+ },\n+ {\n+ \"name\": \"\",\n+ \"fails\": true\n+ },\n+ {\n+ \"name\": \"\",\n+ \"fields\": [[\"a\", \"n\", 9.2]],\n+ \"fails\": true\n+ },\n+ {\n+ \"name\": \"a\",\n+ \"fails\": true\n+ },\n+ {\n+ \"name\": \"m0\",\n+ \"fields\": [\n+ [\"a\", \"n\", 9.2],\n+ [\"b\", \"i\", 9.2],\n+ [\"\", \"s\", 9.2],\n+ [\"d\", \"s\", null],\n+ [\"e\", \"s\"],\n+ [\"f\", \"s\", \"9\"]\n+ ],\n+ \"line\": \"m0 a=9.2,b=9i,f=\\\"9\\\"\"\n+ },\n+ {\n+ \"name\": \"meas, 2\",\n+ \"tags\": [\n+ [\"tag3\", \"a\"],\n+ [\"tag2\", \"b\"],\n+ [\"tag1\", \"c\"]\n+ ],\n+ \"fields\": [\n+ [\"f9\", \"n\", 9.2],\n+ [\"f8\", \"s\", 8.2],\n+ [\"f7\", \"b\", 7.2],\n+ [\"f6\", \"i\", 6.2]\n+ ],\n+ \"time\": \"12345\",\n+ \"line\": \"meas\\\\,\\\\ 2,tag1=c,tag2=b,tag3=a f6=6i,f7=T,f8=\\\"8.2\\\",f9=9.2 12345\"\n+ },\n+ {\n+ \"name\": \"m3\",\n+ \"fields\": [\n+ [\"a\", \"i\", \"9.2\"],\n+ [\"b\", \"n\", \"8.2\"],\n+ [\"c\", \"b\", \"\"],\n+ [\"\", \"b\", \"\"]\n+ ],\n+ \"line\": \"m3 a=9i,b=8.2,c=F\"\n+ },\n+ {\n+ \"name\": \"m4\",\n+ \"tags\": [[\"\", \"whatever\"], [\"t2\"]],\n+ \"fields\": [\n+ [\"a\", \"i\", \"9.2\"],\n+ [\"b\", \"n\", \"8.2\"],\n+ [\"c\", \"b\", \"\"],\n+ [\"\", \"b\", \"\"]\n+ ],\n+ \"line\": \"m4 a=9i,b=8.2,c=F\"\n+ },\n+ {\n+ \"name\": \"m6\",\n+ \"fields\": [[\"a\", \"i\"]],\n+ \"throws\": \"Expected integer\"\n+ },\n+ {\n+ \"name\": \"m7\",\n+ \"fields\": [[\"a\", \"n\"]],\n+ \"throws\": \"Expected float\"\n+ },\n+ {\n+ \"name\": \"m8\",\n+ \"fields\": [[\"a\", \"b\", true]],\n+ \"line\": \"m8,tag1=c,tag2=b,tag3=a a=T\",\n+ \"pointSettings\": {\n+ \"defaultTags\": {\n+ \"tag3\": \"a\",\n+ \"tag2\": \"b\",\n+ \"tag1\": \"c\"\n+ }\n+ }\n+ },\n+ {\n+ \"name\": \"m9\",\n+ \"tags\": [[\"tag2\", \"x\"]],\n+ \"fields\": [[\"a\", \"b\", true]],\n+ \"line\": \"m9,tag1=c,tag2=x,tag3=a a=T\",\n+ \"pointSettings\": {\n+ \"defaultTags\": {\n+ \"tag3\": \"a\",\n+ \"tag2\": \"b\",\n+ \"tag1\": \"c\"\n+ }\n+ }\n+ },\n+ {\n+ \"name\": \"m10\",\n+ \"tags\": [[\"tag1\", \"x\"]],\n+ \"fields\": [[\"a\", \"b\", true]],\n+ \"line\": \"m10,tag1=x,tag2=b,tag3=a a=T 11111\",\n+ \"pointSettings\": {\n+ \"defaultTags\": {\n+ \"tag3\": \"a\",\n+ \"tag2\": \"b\",\n+ \"tag1\": \"c\"\n+ },\n+ \"convertTime\": \"11111\"\n+ }\n+ }\n+]\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/Point.test.ts", "diff": "+import {expect} from 'chai'\n+import Point from '../../src/Point'\n+import pointTables from '../fixture/pointTables.json'\n+import {PointSettings} from '../../src'\n+\n+interface PointTest {\n+ name?: string\n+ tags?: Array<[string, string]>\n+ fields?: Array<[string, 'n' | 's' | 'b' | 'i', any]>\n+ time?: string | number\n+ line: string | undefined\n+ toString: string | undefined\n+ index?: number\n+ fails?: boolean\n+ throws?: string\n+\n+ pointSettings?: {\n+ defaultTags: {[key: string]: string}\n+ convertTime?: string\n+ }\n+}\n+\n+let testIndex = 1\n+function createPoint(test: PointTest): Point {\n+ test.index = testIndex++\n+ const point =\n+ testIndex % 2 == 1\n+ ? new Point(test.name)\n+ : test.name\n+ ? new Point().measurement(test.name)\n+ : new Point()\n+ ;(test.fields || []).forEach(\n+ (field: [string, 'n' | 's' | 'b' | 'i', any]) => {\n+ switch (field[1]) {\n+ case 'n':\n+ point.addNumberField(field[0], field[2])\n+ break\n+ case 's':\n+ point.addStringField(field[0], field[2])\n+ break\n+ case 'b':\n+ point.addBooleanField(field[0], field[2])\n+ break\n+ case 'i':\n+ point.addIntegerField(field[0], field[2])\n+ break\n+ }\n+ }\n+ )\n+ ;(test.tags || []).forEach((tag: [string, string]) => {\n+ point.addTag(tag[0], tag[1])\n+ })\n+ if (test.time) {\n+ point.setTime(test.time)\n+ }\n+ return point\n+}\n+\n+function createPointSettings(pointSettings: {\n+ defaultTags: {[key: string]: string}\n+ convertTime?: string\n+}): PointSettings {\n+ if (pointSettings.convertTime) {\n+ return {\n+ defaultTags: pointSettings.defaultTags,\n+ convertTime: () => pointSettings.convertTime,\n+ }\n+ } else {\n+ return {\n+ defaultTags: pointSettings.defaultTags,\n+ }\n+ }\n+}\n+\n+describe('Point', () => {\n+ describe('toLineProtocol', () => {\n+ ;(pointTables as Array<PointTest>).forEach((test: PointTest) => {\n+ if (test.throws) {\n+ it(`throws error for ${test.name}`, () => {\n+ expect(() => createPoint(test)).to.throw(test.throws)\n+ })\n+ } else {\n+ const point = createPoint(test)\n+ it(`creates line for '${test.index}/${test.name}'`, () => {\n+ if (test.fails) {\n+ expect(point.toString()).to.include('invalid point')\n+ } else {\n+ if (test.pointSettings) {\n+ expect(\n+ point.toLineProtocol(createPointSettings(test.pointSettings))\n+ ).to.be.equal(test.line)\n+ } else {\n+ expect(point.toString()).to.be.equal(test.line)\n+ }\n+ }\n+ })\n+ }\n+ })\n+ })\n+})\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/grammar/escape.test.ts", "diff": "+import {expect} from 'chai'\n+import {escape} from '../../../src/grammar/escape'\n+import escapeTables from '../../fixture/escapeTables.json'\n+\n+describe('escape', () => {\n+ Object.keys(escapeTables).forEach((escaper: string) => {\n+ describe(String(escaper), () => {\n+ ;(escapeTables as any)[escaper].forEach((test: [string, string]) => {\n+ it(`escapes \\`${test[0]}\\` as \\`${test[1]}\\``, () => {\n+ expect((escape as any)[escaper](test[0])).to.equal(test[1])\n+ })\n+ })\n+ })\n+ })\n+})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/Logger.test.ts", "new_path": "test/unit/impl/Logger.test.ts", "diff": "import {expect} from 'chai'\nimport Logger, {setLogger, consoleLogger} from '../../../src/impl/Logger'\n-describe('logger', () => {\n+describe('Logger', () => {\nconst testSet = {message: ' hey', error: 'you'}\nit(\"uses custom logger's error\", () => {\nlet args: Array<any> | undefined\n" }, { "change_type": "MODIFY", "old_path": "tsconfig.json", "new_path": "tsconfig.json", "diff": "\"noUnusedLocals\": true,\n\"moduleResolution\": \"node\",\n\"esModuleInterop\": true,\n- \"sourceMap\": true\n+ \"sourceMap\": true,\n+ \"resolveJsonModule\": true\n},\n\"include\": [\"src/**/*.ts\", \"test/**/*.ts\"],\n\"exclude\": [\"dist\", \"rollup.config.js\"]\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
add point implementation with tests
305,159
09.12.2019 11:34:48
-3,600
13ffffaae5d494a665aa94f161a450a077751af8
add generated time support to Point + tests + refactoring
[ { "change_type": "MODIFY", "old_path": "src/Point.ts", "new_path": "src/Point.ts", "diff": "-import {escape} from './grammar/escape'\n+import {escape} from './util/escape'\nimport {PointSettings} from './options'\n/**\n* Point defines the values that will be written to the database.\n@@ -8,7 +8,7 @@ export default class Point {\nprivate name: string\nprivate tags: {[key: string]: string} = {}\nprivate fields: {[key: string]: string} = {}\n- private time: number | string | undefined\n+ private time: string | undefined\n/**\n* Create a new Point with specified a measurement name.\n@@ -105,7 +105,7 @@ export default class Point {\nreturn this\n}\n- public setTime(value: number | string | undefined): Point {\n+ public setTime(value: string | undefined): Point {\nthis.time = value\nreturn this\n}\n@@ -124,7 +124,10 @@ export default class Point {\n})\nif (fieldsLine.length === 0) return undefined // no fields present\nlet tagsLine = ''\n- const tags = settings ? {...settings.defaultTags, ...this.tags} : this.tags\n+ const tags =\n+ settings && settings.defaultTags\n+ ? {...settings.defaultTags, ...this.tags}\n+ : this.tags\nObject.keys(tags)\n.sort()\n.forEach(x => {\n" }, { "change_type": "MODIFY", "old_path": "src/WriteApi.ts", "new_path": "src/WriteApi.ts", "diff": "+import Point from './Point'\n+\n/**\n* The asynchronous non-blocking API to Write time-series data into InfluxDB 2.0.\n* <p>\n* <p>\n*/\nexport default interface WriteApi {\n+ /**\n+ * Instructs to use the following default tags when writing points.\n+ * Not applicable for writing records/lines.\n+ * @param tags\n+ */\n+ useDefaultTags(tags: {[key: string]: string}): void\n+\n/**\n* Write Line Protocol record.\n*\n@@ -19,6 +28,20 @@ export default interface WriteApi {\n*/\nwriteRecords(records: Array<string>): void\n+ /**\n+ * Write point.\n+ *\n+ * @param records lines in InfluxDB Line Protocol\n+ */\n+ writePoint(point: Point): void\n+\n+ /**\n+ * Write point.\n+ *\n+ * @param records lines in InfluxDB Line Protocol\n+ */\n+ writePoints(points: Array<Point>): void\n+\n/**\n* Flushes pending writes to the server.\n* @return completition promise\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -4,10 +4,14 @@ import {\nDEFAULT_WriteOptions,\nClientOptions,\nDEFAULT_ConnectionOptions,\n+ PointSettings,\n} from '../options'\nimport {Transport, SendOptions} from '../transport'\nimport Logger from './Logger'\nimport {getRetryDelay, HttpError} from '../errors'\n+import Point from '../Point'\n+import {escape} from '../util/escape'\n+import {currentTimes} from '../util/currentTime'\nclass WriteBuffer {\nlength = 0\n@@ -53,11 +57,12 @@ class WriteBuffer {\n}\n}\n-export default class WriteApiImpl implements WriteApi {\n+export default class WriteApiImpl implements WriteApi, PointSettings {\nprivate buffer: WriteBuffer\nprivate closed = false\nprivate _timeoutHandle: any = undefined\n+ private currentTime: () => string\nconstructor(\ntransport: Transport,\n@@ -73,6 +78,7 @@ export default class WriteApiImpl implements WriteApi {\n...DEFAULT_WriteOptions,\n...clientOptions.writeOptions,\n}\n+ this.currentTime = currentTimes[precision]\nconst sendOptions: Partial<SendOptions> = {\nmethod: 'POST',\nmaxRetries: 0, // we control manual retry attempts\n@@ -176,6 +182,15 @@ export default class WriteApiImpl implements WriteApi {\nthis.buffer.add(records[i])\n}\n}\n+ writePoint(point: Point): void {\n+ const line = point.toLineProtocol(this)\n+ if (line) this.buffer.add(line)\n+ }\n+ writePoints(points: Point[]): void {\n+ for (let i = 0; i < points.length; i++) {\n+ this.writePoint(points[i])\n+ }\n+ }\nflush(): Promise<void> {\nreturn this.buffer.flush()\n}\n@@ -188,4 +203,23 @@ export default class WriteApiImpl implements WriteApi {\nthis._clearFlushTimeout()\nthis.closed = true\n}\n+\n+ // PointSettings\n+ defaultTags: {[key: string]: string} | undefined\n+ useDefaultTags(tags: {[key: string]: string}): WriteApi {\n+ this.defaultTags = undefined\n+ Object.keys(tags).forEach((key: string) => {\n+ ;(this.defaultTags || (this.defaultTags = {}))[key] = escape.tag(\n+ tags[key]\n+ )\n+ })\n+ return this\n+ }\n+ convertTime(value: string | undefined): string | undefined {\n+ if (typeof value === 'string') {\n+ return value ? value : undefined\n+ } else {\n+ return this.currentTime()\n+ }\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "src/index.ts", "new_path": "src/index.ts", "diff": "export * from './options'\nexport * from './errors'\n+export * from './util/escape'\n+export * from './util/currentTime'\nexport {default as Point} from './Point'\nexport {default as WriteApi} from './WriteApi'\nexport {default as InfluxDB} from './InfluxDB'\n" }, { "change_type": "MODIFY", "old_path": "src/options.ts", "new_path": "src/options.ts", "diff": "@@ -54,6 +54,6 @@ export const enum WritePrecission {\n}\nexport interface PointSettings {\n- defaultTags: {[key: string]: string}\n- convertTime?: (value: undefined | string | number) => string | undefined\n+ defaultTags?: {[key: string]: string}\n+ convertTime?: (value: string | undefined) => string | undefined\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/util/currentTime.ts", "diff": "+import {WritePrecission} from '../options'\n+\n+declare let process: any\n+const zeroPadding = '000000000'\n+let useHrTime: boolean = false\n+\n+export function useProcessHrtime(use: boolean): boolean {\n+ return (useHrTime = use && process && typeof process.hrtime === 'function')\n+}\n+useProcessHrtime(true) // preffer node\n+\n+let nanos: () => string = () => {\n+ if (useHrTime) {\n+ const hrTime = process.hrtime() as [number, number]\n+ const nanos = String(hrTime[1] % 1000000)\n+ return String(Date.now()) + zeroPadding.substr(0, 6 - nanos.length) + nanos\n+ } else {\n+ return String(Date.now()) + zeroPadding.substr(0, 6)\n+ }\n+}\n+\n+const micros: () => string = () => {\n+ if (useHrTime) {\n+ const hrTime = process.hrtime() as [number, number]\n+ const micros = String(Math.trunc(hrTime[1] / 1000) % 1000)\n+ return (\n+ String(Date.now()) + zeroPadding.substr(0, 3 - micros.length) + micros\n+ )\n+ } else {\n+ return String(Date.now()) + zeroPadding.substr(0, 3)\n+ }\n+}\n+const millis: () => string = () => String(Date.now())\n+const seconds: () => string = () => String(Math.floor(Date.now() / 1000))\n+\n+export const currentTimes = Object.freeze({\n+ [String(WritePrecission.s)]: seconds,\n+ [String(WritePrecission.ms)]: millis,\n+ [String(WritePrecission.us)]: micros,\n+ [String(WritePrecission.ns)]: nanos,\n+})\n" }, { "change_type": "RENAME", "old_path": "src/grammar/escape.ts", "new_path": "src/util/escape.ts", "diff": "" }, { "change_type": "MODIFY", "old_path": "test/unit/Point.test.ts", "new_path": "test/unit/Point.test.ts", "diff": "@@ -7,7 +7,7 @@ interface PointTest {\nname?: string\ntags?: Array<[string, string]>\nfields?: Array<[string, 'n' | 's' | 'b' | 'i', any]>\n- time?: string | number\n+ time?: string\nline: string | undefined\ntoString: string | undefined\nindex?: number\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -6,6 +6,8 @@ import {\nWritePrecission,\nDEFAULT_WriteOptions,\nWriteOptions,\n+ Point,\n+ WriteApi,\n} from '../../../src'\nimport WriteApiImpl from '../../../src/impl/WriteApiImpl'\nimport {collectLogging, CollectedLogs} from '../../util'\n@@ -20,7 +22,7 @@ const ORG = 'org'\nconst BUCKET = 'bucket'\nconst PRECISSION = WritePrecission.s\n-const WRITE_PATH = `/write?org=${ORG}&bucket=${BUCKET}&precission=${PRECISSION}`\n+const WRITE_PATH_NS = `/write?org=${ORG}&bucket=${BUCKET}&precission=ns`\ndescribe('WriteApiImpl', () => {\nbeforeEach(() => {\n@@ -93,7 +95,7 @@ describe('WriteApiImpl', () => {\nsubject.close()\ncollectLogging.after()\n})\n- it('flushes the response in specified batchSize', async () => {\n+ it('flushes the data in specified batchSize', async () => {\nuseSubject({flushInterval: 0, batchSize: 1})\nsubject.writeRecord('test value=1')\nsubject.writeRecords(['test value=2', 'test value=3'])\n@@ -138,7 +140,7 @@ describe('WriteApiImpl', () => {\nsubject.close()\ncollectLogging.after()\n})\n- it('flushes the response automatically', async () => {\n+ it('flushes the records automatically', async () => {\nuseSubject({flushInterval: 5, maxRetries: 0, batchSize: 10})\nsubject.writeRecord('test value=1')\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\n@@ -153,13 +155,13 @@ describe('WriteApiImpl', () => {\n})\n})\ndescribe('usage of server API', () => {\n- let subject: WriteApiImpl\n+ let subject: WriteApi\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISSION, {\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, WritePrecission.ns, {\n...clientOptions,\nwriteOptions,\n- })\n+ }).useDefaultTags({xtra: '1'})\n}\nbeforeEach(() => {\n// logs = collectLogging.decorate()\n@@ -169,27 +171,60 @@ describe('WriteApiImpl', () => {\nsubject.close()\ncollectLogging.after()\n})\n- it('flushes the response without errors', async () => {\n+ it('flushes the records without errors', async () => {\nuseSubject({flushInterval: 5, maxRetries: 1, batchSize: 10})\nlet requests = 0\n+ const messages: string[] = []\nnock(clientOptions.url)\n- .post(WRITE_PATH)\n+ .post(WRITE_PATH_NS)\n.reply((_uri, _requestBody) => {\nrequests++\n- return [requests % 2 ? 429 : 200, 'yes', {'retry-after': '1'}]\n+ if (requests % 2) {\n+ return [429, '', {'retry-after': '1'}]\n+ } else {\n+ messages.push(_requestBody.toString())\n+ return [200, '', {'retry-after': '1'}]\n+ }\n})\n.persist()\n- subject.writeRecord('test value=1')\n+ subject.writePoint(\n+ new Point('test')\n+ .addTag('t', ' ')\n+ .addNumberField('value', 1)\n+ .setTime('')\n+ )\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\nexpect(logs.error).to.length(0)\nexpect(logs.warn).to.length(1)\n- subject.writeRecord('test value=2')\n+ subject.writePoints([\n+ new Point('test').addNumberField('value', 2),\n+ new Point('test').addNumberField('value', 3),\n+ new Point('test').addNumberField('value', 4).setTime('1'),\n+ ])\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\nexpect(logs.error).to.length(0)\nexpect(logs.warn).to.length(2)\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush\nexpect(logs.error).to.length(0)\nexpect(logs.warn).to.length(2)\n+ expect(messages).to.have.length(2)\n+ expect(messages[0]).to.equal('test,t=\\\\ ,xtra=1 value=1')\n+ const lines = messages[1].split('\\n')\n+ expect(lines).has.length(3)\n+ expect(lines[0]).to.satisfy((line: string) =>\n+ line.startsWith('test,xtra=1 value=2')\n+ )\n+ expect(lines[0].substring(lines[0].lastIndexOf(' ') + 1)).to.have.length(\n+ String(Date.now()).length + 6 // nanosecond precision\n+ )\n+ expect(lines[1]).to.satisfy((line: string) =>\n+ line.startsWith('test,xtra=1 value=3')\n+ )\n+ expect(lines[0].substring(lines[0].lastIndexOf(' ') + 1)).to.have.length(\n+ String(Date.now()).length + 6 // nanosecond precision\n+ )\n+ expect(lines[2]).to.be.equal('test,xtra=1 value=4 1')\n+ lines.forEach(line => {})\nawait subject.flush().then(() => {\nexpect(logs.error).to.length(0)\n})\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/util/currentTime.test.ts", "diff": "+import {currentTimes, useProcessHrtime} from '../../../src'\n+import {expect} from 'chai'\n+\n+describe('currentTime', () => {\n+ let useHrTime: boolean\n+ beforeEach(() => {\n+ useHrTime = useProcessHrtime(true)\n+ })\n+ afterEach(() => {\n+ useProcessHrtime(useHrTime)\n+ })\n+ ;[true, false].forEach((useProcessApi: boolean) => {\n+ describe(\n+ useProcessApi\n+ ? 'with the help of process.hrtime'\n+ : 'using just Date.now()',\n+ () => {\n+ beforeEach(() => {\n+ useHrTime = useProcessHrtime(useProcessApi)\n+ })\n+ it('calculates time in seconds', () => {\n+ const val = currentTimes['s']()\n+ const ms = Date.now()\n+ expect(val).to.have.length(\n+ String(Math.floor(Date.now() / 1000)).length\n+ )\n+ expect(Math.abs(parseInt(val) - ms / 1000)).to.be.lessThan(5)\n+ })\n+ it('calculates time in milliseconds', () => {\n+ const val = currentTimes['ms']()\n+ const ms = Date.now()\n+ expect(val).to.have.length(String(Date.now()).length)\n+ expect(Math.abs(parseInt(val) - ms)).to.be.lessThan(5000)\n+ })\n+ it('calculates time in microseconds', () => {\n+ const val = currentTimes['us']()\n+ const ms = Date.now()\n+ expect(val).to.have.length(String(Date.now()).length + 3)\n+ expect(Math.abs(parseInt(val) - ms * 1000)).to.be.lessThan(5000000)\n+ })\n+ it('calculates time in nanoseconds', () => {\n+ const val = currentTimes['ns']()\n+ const ms = Date.now()\n+ expect(val).to.have.length(String(Date.now()).length + 6)\n+ expect(Math.abs(parseInt(val) - ms * 1000000)).to.be.lessThan(\n+ 5000000000\n+ )\n+ })\n+ }\n+ )\n+ })\n+})\n" }, { "change_type": "RENAME", "old_path": "test/unit/grammar/escape.test.ts", "new_path": "test/unit/util/escape.test.ts", "diff": "import {expect} from 'chai'\n-import {escape} from '../../../src/grammar/escape'\n+import {escape} from '../../../src'\nimport escapeTables from '../../fixture/escapeTables.json'\ndescribe('escape', () => {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
add generated time support to Point + tests + refactoring
305,159
09.12.2019 12:45:45
-3,600
4d28d26338d5b46658b3632c9b60f9e3b76beca8
chore: access current time functions also by name
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"scripts\": {\n\"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n- \"clean\": \"rimraf dist build coverage doc\",\n+ \"clean\": \"rimraf dist build coverage .nyc_output doc\",\n\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' test/unit/*.test.ts\",\n" }, { "change_type": "MODIFY", "old_path": "src/util/currentTime.ts", "new_path": "src/util/currentTime.ts", "diff": "@@ -38,4 +38,8 @@ export const currentTimes = Object.freeze({\n[String(WritePrecission.ms)]: millis,\n[String(WritePrecission.us)]: micros,\n[String(WritePrecission.ns)]: nanos,\n+ seconds,\n+ millis,\n+ micros,\n+ nanos,\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: access current time functions also by name
305,159
09.12.2019 15:53:49
-3,600
42cc0bc7a59ad3725ad50861f12299cfeba698eb
feat: add codecov for reporting code coverage
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n\"clean\": \"rimraf dist build coverage .nyc_output doc\",\n+ \"codecov\": \"nyc report --reporter=text-lcov > coverage.lcov && codecov\",\n\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' test/unit/*.test.ts\",\n\"@typescript-eslint/eslint-plugin\": \"^2.9.0\",\n\"@typescript-eslint/parser\": \"^2.9.0\",\n\"chai\": \"^4.2.0\",\n+ \"codedoc\": \"^0.0.0\",\n\"eslint\": \"^6.7.1\",\n\"eslint-config-prettier\": \"^6.7.0\",\n\"eslint-plugin-prettier\": \"^3.1.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -459,6 +459,10 @@ clone@~0.1.9:\nversion \"0.1.19\"\nresolved \"https://registry.yarnpkg.com/clone/-/clone-0.1.19.tgz#613fb68639b26a494ac53253e15b1a6bd88ada85\"\n+codedoc@^0.0.0:\n+ version \"0.0.0\"\n+ resolved \"https://registry.yarnpkg.com/codedoc/-/codedoc-0.0.0.tgz#44c601a76aa0362aad4232661297b1e42eb46252\"\n+\ncolor-convert@^1.9.0:\nversion \"1.9.3\"\nresolved \"https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8\"\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add codecov for reporting code coverage
305,159
09.12.2019 15:56:37
-3,600
40ed66916b63ad2d8b615a7743df040827a6db58
feat: add circle CI
[ { "change_type": "ADD", "old_path": null, "new_path": ".circleci/config.yaml", "diff": "+version: 2.1\n+\n+workflows:\n+ build:\n+ jobs:\n+ - lint\n+ - unit-tests:\n+ version: 8\n+ - coverage\n+\n+jobs:\n+ lint:\n+ docker:\n+ - image: circleci/node:8\n+ steps:\n+ - checkout\n+ - restore_cache:\n+ name: Restore Yarn Package Cache\n+ keys:\n+ - yarn-packages-{{ checksum \"yarn.lock\" }}\n+ - run:\n+ name: Install Dependencies\n+ command: yarn install --frozen-lockfile\n+ - save_cache:\n+ name: Save Yarn Package Cache\n+ key: yarn-packages-{{ checksum \"yarn.lock\" }}\n+ paths:\n+ - ~/.cache/yarn\n+ - run:\n+ name: Run lint\n+ command: yarn lint\n+ unit-tests:\n+ parameters:\n+ version:\n+ type: string\n+ docker:\n+ - image: circleci/node:<< parameters.version >>\n+ steps:\n+ - checkout\n+ - restore_cache:\n+ name: Restore Yarn Package Cache\n+ keys:\n+ - yarn-packages-{{ checksum \"yarn.lock\" }}\n+ - run:\n+ name: Install Dependencies\n+ command: yarn install --frozen-lockfile\n+ - save_cache:\n+ name: Save Yarn Package Cache\n+ key: yarn-packages-{{ checksum \"yarn.lock\" }}\n+ paths:\n+ - ~/.cache/yarn\n+ - run:\n+ name: Run test\n+ command: yarn test:unit\n+ coverage:\n+ parameters:\n+ version:\n+ type: string\n+ docker:\n+ - image: circleci/node:<< parameters.version >>\n+ steps:\n+ - checkout\n+ - restore_cache:\n+ name: Restore Yarn Package Cache\n+ keys:\n+ - yarn-packages-{{ checksum \"yarn.lock\" }}\n+ - run:\n+ name: Install Dependencies\n+ command: yarn install --frozen-lockfile\n+ - save_cache:\n+ name: Save Yarn Package Cache\n+ key: yarn-packages-{{ checksum \"yarn.lock\" }}\n+ paths:\n+ - ~/.cache/yarn\n+ - run:\n+ name: Run tests and coverage\n+ command: |\n+ yarn test:unit\n+ yarn codecov\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "-# InfluxDB 2.0 JavaScript client\n+# influxdb-client-javascript\n+\n+[![CircleCI](https://circleci.com/gh/sranka/influxdb-client-java.svg?style=svg)](https://circleci.com/gh/sranka/influxdb-client-java)\n+[![codecov](https://codecov.io/gh/sranka/influxdb-client-java/branch/master/graph/badge.svg)](https://codecov.io/gh/sranka/influxdb-client-java)\n+[![License](https://img.shields.io/github/license/sranka/influxdb-client-java.svg)](https://github.com/sranka/influxdb-client-java/blob/master/LICENSE)\n+[![GitHub issues](https://img.shields.io/github/issues-raw/sranka/influxdb-client-java.svg)](https://github.com/sranka/influxdb-client-java/issues)\n+[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/sranka/influxdb-client-java.svg)](https://github.com/sranka/influxdb-client-java/pulls)\n+\n+This repository contains the reference javascript client for InfluxDB 2.0.\n## Disclaimer\n@@ -8,10 +16,27 @@ This library is a work in progress and should not be considered production ready\nToDo\n-## Development\n+## Build Requirements\n+\n+- node v12.13.1\n+- yarn 19.4. or higher\n+\n+Once these are in place you can run all unit tests with:\n+\n+```bash\n+$ yarn test:unit\n+```\n+\n+If the tests pass, you can build with:\n+\n+```bash\n+$ yarn build\n+```\n+\n+## Contributing\n-### Requirements\n+If you would like to contribute code you can do through GitHub by forking the repository and sending a pull request into the `master` branch.\n-- Node 10.x or higher\n+## License\n-### ToDo\n\\ No newline at end of file\n+The InfluxDB 2.0 JVM Based Clients are released under the [MIT License](https://opensource.org/licenses/MIT).\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add circle CI
305,159
09.12.2019 16:11:30
-3,600
0ec3556d0a2c29a9cc9afded2576a0bc8bbf7e83
chore: increase node version
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -5,13 +5,13 @@ workflows:\njobs:\n- lint\n- unit-tests:\n- version: '8'\n+ version: '12'\n- coverage\njobs:\nlint:\ndocker:\n- - image: circleci/node:8\n+ - image: circleci/node:12\nsteps:\n- checkout\n- restore_cache:\n@@ -54,10 +54,8 @@ jobs:\ncommand: yarn test:unit\ncoverage:\nparameters:\n- version:\n- type: string\ndocker:\n- - image: circleci/node:<< parameters.version >>\n+ - image: circleci/node:12\nsteps:\n- checkout\n- restore_cache:\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: increase node version
305,159
09.12.2019 16:24:16
-3,600
5cb21eaf67536d1f574a77bbdb20124a9c164190
chore: repair lint errors
[ { "change_type": "MODIFY", "old_path": "src/util/currentTime.ts", "new_path": "src/util/currentTime.ts", "diff": "@@ -2,14 +2,14 @@ import {WritePrecission} from '../options'\ndeclare let process: any\nconst zeroPadding = '000000000'\n-let useHrTime: boolean = false\n+let useHrTime = false\nexport function useProcessHrtime(use: boolean): boolean {\nreturn (useHrTime = use && process && typeof process.hrtime === 'function')\n}\nuseProcessHrtime(true) // preffer node\n-let nanos: () => string = () => {\n+function nanos(): string {\nif (useHrTime) {\nconst hrTime = process.hrtime() as [number, number]\nconst nanos = String(hrTime[1] % 1000000)\n@@ -19,7 +19,7 @@ let nanos: () => string = () => {\n}\n}\n-const micros: () => string = () => {\n+function micros(): string {\nif (useHrTime) {\nconst hrTime = process.hrtime() as [number, number]\nconst micros = String(Math.trunc(hrTime[1] / 1000) % 1000)\n@@ -30,8 +30,12 @@ const micros: () => string = () => {\nreturn String(Date.now()) + zeroPadding.substr(0, 3)\n}\n}\n-const millis: () => string = () => String(Date.now())\n-const seconds: () => string = () => String(Math.floor(Date.now() / 1000))\n+function millis(): string {\n+ return String(Date.now())\n+}\n+function seconds(): string {\n+ return String(Math.floor(Date.now() / 1000))\n+}\nexport const currentTimes = Object.freeze({\n[String(WritePrecission.s)]: seconds,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: repair lint errors
305,159
09.12.2019 16:25:00
-3,600
b69c067266e7047e2c3086233d27003c55a0d703
chore: repair coverage job in circle ci
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -71,7 +71,7 @@ jobs:\npaths:\n- ~/.cache/yarn\n- run:\n- name: Run tests and coverage\n+ name: Run tests and reports coverage\ncommand: |\n- yarn test:unit\n+ yarn coverage\nyarn codecov\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"codecov\": \"nyc report --reporter=text-lcov > coverage.lcov && codecov\",\n\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n- \"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' test/unit/*.test.ts\",\n+ \"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts'\",\n\"test:watch\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --watch-extensions ts --watch\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n\"lint\": \"eslint 'src/**/*.ts'\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: repair coverage job in circle ci
305,159
09.12.2019 16:31:29
-3,600
738807e3a00e0276e85b1ed21fa75c832e1b475c
feat: add codecov dev dependency
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"@typescript-eslint/eslint-plugin\": \"^2.9.0\",\n\"@typescript-eslint/parser\": \"^2.9.0\",\n\"chai\": \"^4.2.0\",\n- \"codedoc\": \"^0.0.0\",\n+ \"codecov\": \"^3.6.1\",\n\"eslint\": \"^6.7.1\",\n\"eslint-config-prettier\": \"^6.7.0\",\n\"eslint-plugin-prettier\": \"^3.1.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -199,6 +199,12 @@ acorn@^7.1.0:\nversion \"7.1.0\"\nresolved \"https://registry.yarnpkg.com/acorn/-/acorn-7.1.0.tgz#949d36f2c292535da602283586c2477c57eb2d6c\"\n+agent-base@^4.3.0:\n+ version \"4.3.0\"\n+ resolved \"https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee\"\n+ dependencies:\n+ es6-promisify \"^5.0.0\"\n+\najv@^6.10.0, ajv@^6.10.2:\nversion \"6.10.2\"\nresolved \"https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52\"\n@@ -256,6 +262,10 @@ argparse@^1.0.7:\ndependencies:\nsprintf-js \"~1.0.2\"\n+argv@^0.0.2:\n+ version \"0.0.2\"\n+ resolved \"https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab\"\n+\narray-from@^2.1.1:\nversion \"2.1.1\"\nresolved \"https://registry.yarnpkg.com/array-from/-/array-from-2.1.1.tgz#cfe9d8c26628b9dc5aecc62a9f5d8f1f352c1195\"\n@@ -459,9 +469,15 @@ clone@~0.1.9:\nversion \"0.1.19\"\nresolved \"https://registry.yarnpkg.com/clone/-/clone-0.1.19.tgz#613fb68639b26a494ac53253e15b1a6bd88ada85\"\n-codedoc@^0.0.0:\n- version \"0.0.0\"\n- resolved \"https://registry.yarnpkg.com/codedoc/-/codedoc-0.0.0.tgz#44c601a76aa0362aad4232661297b1e42eb46252\"\n+codecov@^3.6.1:\n+ version \"3.6.1\"\n+ resolved \"https://registry.yarnpkg.com/codecov/-/codecov-3.6.1.tgz#f39fc49413445555f81f8e3ca5730992843b4517\"\n+ dependencies:\n+ argv \"^0.0.2\"\n+ ignore-walk \"^3.0.1\"\n+ js-yaml \"^3.13.1\"\n+ teeny-request \"^3.11.3\"\n+ urlgrey \"^0.4.4\"\ncolor-convert@^1.9.0:\nversion \"1.9.3\"\n@@ -575,7 +591,7 @@ crypto-browserify@^3.11.0:\nrandombytes \"^2.0.0\"\nrandomfill \"^1.0.3\"\[email protected]:\[email protected], debug@^3.1.0:\nversion \"3.2.6\"\nresolved \"https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b\"\ndependencies:\n@@ -711,6 +727,16 @@ es6-error@^4.0.1:\nversion \"4.1.1\"\nresolved \"https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d\"\n+es6-promise@^4.0.3:\n+ version \"4.2.8\"\n+ resolved \"https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a\"\n+\n+es6-promisify@^5.0.0:\n+ version \"5.0.0\"\n+ resolved \"https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203\"\n+ dependencies:\n+ es6-promise \"^4.0.3\"\n+\[email protected], escape-string-regexp@^1.0.5:\nversion \"1.0.5\"\nresolved \"https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4\"\n@@ -1071,6 +1097,13 @@ hosted-git-info@^2.1.4:\nversion \"2.8.5\"\nresolved \"https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.5.tgz#759cfcf2c4d156ade59b0b2dfabddc42a6b9c70c\"\n+https-proxy-agent@^2.2.1:\n+ version \"2.2.4\"\n+ resolved \"https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b\"\n+ dependencies:\n+ agent-base \"^4.3.0\"\n+ debug \"^3.1.0\"\n+\niconv-lite@^0.4.24:\nversion \"0.4.24\"\nresolved \"https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b\"\n@@ -1081,6 +1114,12 @@ idb-wrapper@^1.5.0:\nversion \"1.7.2\"\nresolved \"https://registry.yarnpkg.com/idb-wrapper/-/idb-wrapper-1.7.2.tgz#8251afd5e77fe95568b1c16152eb44b396767ea2\"\n+ignore-walk@^3.0.1:\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37\"\n+ dependencies:\n+ minimatch \"^3.0.4\"\n+\nignore@^4.0.6:\nversion \"4.0.6\"\nresolved \"https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc\"\n@@ -1629,6 +1668,10 @@ [email protected]:\nobject.getownpropertydescriptors \"^2.0.3\"\nsemver \"^5.7.0\"\n+node-fetch@^2.2.0:\n+ version \"2.6.0\"\n+ resolved \"https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd\"\n+\nnormalize-package-data@^2.3.2:\nversion \"2.5.0\"\nresolved \"https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8\"\n@@ -2413,6 +2456,14 @@ table@^5.2.3:\nslice-ansi \"^2.1.0\"\nstring-width \"^3.0.0\"\n+teeny-request@^3.11.3:\n+ version \"3.11.3\"\n+ resolved \"https://registry.yarnpkg.com/teeny-request/-/teeny-request-3.11.3.tgz#335c629f7645e5d6599362df2f3230c4cbc23a55\"\n+ dependencies:\n+ https-proxy-agent \"^2.2.1\"\n+ node-fetch \"^2.2.0\"\n+ uuid \"^3.3.2\"\n+\nterser@^4.1.0:\nversion \"4.4.0\"\nresolved \"https://registry.yarnpkg.com/terser/-/terser-4.4.0.tgz#22c46b4817cf4c9565434bfe6ad47336af259ac3\"\n@@ -2544,6 +2595,10 @@ urix@^0.1.0:\nversion \"0.1.0\"\nresolved \"https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72\"\n+urlgrey@^0.4.4:\n+ version \"0.4.4\"\n+ resolved \"https://registry.yarnpkg.com/urlgrey/-/urlgrey-0.4.4.tgz#892fe95960805e85519f1cd4389f2cb4cbb7652f\"\n+\nutil-deprecate@~1.0.1:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf\"\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add codecov dev dependency
305,159
09.12.2019 19:57:43
-3,600
5cb97d80c5ed122550c456033ca858a66b6f6d9f
feat: trying to make code coverage work
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n\"clean\": \"rimraf dist build coverage .nyc_output doc\",\n- \"codecov\": \"nyc report --reporter=text-lcov > coverage.lcov && codecov\",\n+ \"codecov\": \"nyc report --reporter=lcov && codecov\",\n\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts'\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: trying to make code coverage work
305,159
09.12.2019 20:38:43
-3,600
ac2e96fcb86c1ec415960c1dddccc64801d72309
chore: simplify circle CI
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -3,32 +3,11 @@ version: 2.1\nworkflows:\nbuild:\njobs:\n- - lint\n- unit-tests:\nversion: '12'\n- coverage\njobs:\n- lint:\n- docker:\n- - image: circleci/node:12\n- steps:\n- - checkout\n- - restore_cache:\n- name: Restore Yarn Package Cache\n- keys:\n- - yarn-packages-{{ checksum \"yarn.lock\" }}\n- - run:\n- name: Install Dependencies\n- command: yarn install --frozen-lockfile\n- - save_cache:\n- name: Save Yarn Package Cache\n- key: yarn-packages-{{ checksum \"yarn.lock\" }}\n- paths:\n- - ~/.cache/yarn\n- - run:\n- name: Run lint\n- command: yarn lint\nunit-tests:\nparameters:\nversion:\n@@ -51,7 +30,9 @@ jobs:\n- ~/.cache/yarn\n- run:\nname: Run test\n- command: yarn test:unit\n+ command: |\n+ yarn lint\n+ yarn test:unit\ncoverage:\nparameters:\ndocker:\n@@ -71,7 +52,7 @@ jobs:\npaths:\n- ~/.cache/yarn\n- run:\n- name: Run tests and reports coverage\n+ name: Run tests and reports coverage to codecov\ncommand: |\nyarn coverage\nyarn codecov\n" }, { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -10,7 +10,7 @@ This repository contains the reference javascript client for InfluxDB 2.0.\n## Disclaimer\n-This library is a work in progress and should not be considered production ready.\n+This library is a work in progress and should not be considered production ready yet.\n## Usage\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: simplify circle CI
305,159
09.12.2019 20:51:55
-3,600
f06d0c05703e333a3b41fb08096f88a81b0989e4
chore: enhance clean target, add default codecov.yml
[ { "change_type": "ADD", "old_path": null, "new_path": "codecov.yml", "diff": "+coverage:\n+ status:\n+ project:\n+ default: true\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"scripts\": {\n\"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n- \"clean\": \"rimraf dist build coverage .nyc_output doc\",\n+ \"clean\": \"rimraf dist build coverage .nyc_output doc *.lcov\",\n\"codecov\": \"nyc report --reporter=lcov && codecov\",\n\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: enhance clean target, add default codecov.yml
305,159
09.12.2019 21:23:46
-3,600
0ceb27952bcbf99ab575e7d7fcaaf6c6f7bf2199
chore: disable gcov coverage
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n\"clean\": \"rimraf dist build coverage .nyc_output doc *.lcov\",\n- \"codecov\": \"nyc report --reporter=lcov && codecov\",\n+ \"codecov\": \"nyc report --reporter=lcov && codecov --disable=gcov\",\n\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts'\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: disable gcov coverage
305,159
10.12.2019 09:46:15
-3,600
90ea379001f18708734b555d7f3bc13aaa34a86d
chore: change badges
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "# influxdb-client-javascript\n-[![CircleCI](https://circleci.com/gh/sranka/influxdb-client-js.svg?style=svg)](https://circleci.com/gh/sranka/influxdb-client-js)\n-[![codecov](https://codecov.io/gh/sranka/influxdb-client-js/branch/master/graph/badge.svg)](https://codecov.io/gh/sranka/influxdb-client-js)\n-[![License](https://img.shields.io/github/license/sranka/influxdb-client-js.svg)](https://github.com/sranka/influxdb-client-js/blob/master/LICENSE)\n-[![GitHub issues](https://img.shields.io/github/issues-raw/sranka/influxdb-client-js.svg)](https://github.com/sranka/influxdb-client-js/issues)\n-[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/sranka/influxdb-client-js.svg)](https://github.com/sranka/influxdb-client-js/pulls)\n+[![CircleCI](https://circleci.com/gh/bonitoo-io/influxdb-client-js.svg?style=svg)](https://circleci.com/gh/bonitoo-io/influxdb-client-js)\n+[![codecov](https://codecov.io/gh/bonitoo-io/influxdb-client-js/branch/master/graph/badge.svg)](https://codecov.io/gh/bonitoo-io/influxdb-client-js)\n+[![License](https://img.shields.io/github/license/bonitoo-io/influxdb-client-js.svg)](https://github.com/bonitoo-io/influxdb-client-js/blob/master/LICENSE)\n+[![GitHub issues](https://img.shields.io/github/issues-raw/bonitoo-io/influxdb-client-js.svg)](https://github.com/bonitoo-io/influxdb-client-js/issues)\n+[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/bonitoo-io/influxdb-client-js.svg)](https://github.com/bonitoo-io/influxdb-client-js/pulls)\nThis repository contains the reference javascript client for InfluxDB 2.0.\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: change badges
305,159
10.12.2019 10:19:58
-3,600
58b8949b9fe2e8b337ca40b5a8f8118287222792
chore: trying to fix code coverage with circle CI
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n\"clean\": \"rimraf dist build coverage .nyc_output doc *.lcov\",\n- \"codecov\": \"nyc report --reporter=lcov && codecov --disable=gcov\",\n+ \"codecov\": \"nyc report --reporter=text-lcov > coverage/coverage.lcov && codecov\",\n\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts'\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: trying to fix code coverage with circle CI
305,159
10.12.2019 10:39:53
-3,600
b4f0226153587a3d21ab5aca08cfae804af1875b
chore: add and use CI targets from package.json
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -28,11 +28,19 @@ jobs:\nkey: yarn-packages-{{ checksum \"yarn.lock\" }}\npaths:\n- ~/.cache/yarn\n+ - run: mkdir reports\n- run:\n- name: Run test\n+ name: Run tests\ncommand: |\n- yarn lint\n- yarn test:unit\n+ yarn test:unit:ci\n+ yarn lint:ci\n+ # Upload results\n+ - store_test_results:\n+ path: reports\n+ - store_artifacts:\n+ path: ./reports/mocha/test-results.xml\n+ - store_artifacts:\n+ path: ./reports/eslint/eslint.xml\ncoverage:\nparameters:\ndocker:\n@@ -56,3 +64,6 @@ jobs:\ncommand: |\nyarn coverage\nyarn codecov\n+ - store_artifacts: # upload test coverage as artifact\n+ path: ./coverage/coverage.lcov\n+ prefix: tests\n" }, { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "@@ -7,3 +7,4 @@ doc\n.DS_Store\n.nyc_output\n*.lcov\n+reports\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"coverage\": \"nyc yarn run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts'\",\n+ \"test:unit:ci\": \"yarn run test:unit --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml\",\n\"test:watch\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --watch-extensions ts --watch\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n\"lint\": \"eslint 'src/**/*.ts'\",\n+ \"lint:ci\": \"yarn run lint --format junit --output-file reports/eslint/eslint.xml\",\n\"lint:fix\": \"eslint --fix 'src/**/*.ts'\"\n},\n\"homepage\": \"https://github.com/influxdata/influxdb2-client-js\",\n\"eslint-config-prettier\": \"^6.7.0\",\n\"eslint-plugin-prettier\": \"^3.1.1\",\n\"mocha\": \"^6.2.2\",\n+ \"mocha-junit-reporter\": \"^1.23.1\",\n\"nock\": \"^11.7.0\",\n\"nyc\": \"^14.1.1\",\n\"prettier\": \"^1.19.1\",\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -436,6 +436,10 @@ chardet@^0.7.0:\nversion \"0.7.0\"\nresolved \"https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e\"\n+charenc@~0.0.1:\n+ version \"0.0.2\"\n+ resolved \"https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667\"\n+\ncheck-error@^1.0.2:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82\"\n@@ -575,6 +579,10 @@ cross-spawn@^6.0.5:\nshebang-command \"^1.2.0\"\nwhich \"^1.2.9\"\n+crypt@~0.0.1:\n+ version \"0.0.2\"\n+ resolved \"https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b\"\n+\ncrypto-browserify@^3.11.0:\nversion \"3.12.0\"\nresolved \"https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec\"\n@@ -597,6 +605,12 @@ [email protected], debug@^3.1.0:\ndependencies:\nms \"^2.1.1\"\n+debug@^2.2.0:\n+ version \"2.6.9\"\n+ resolved \"https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f\"\n+ dependencies:\n+ ms \"2.0.0\"\n+\ndebug@^4.0.1, debug@^4.1.0, debug@^4.1.1:\nversion \"4.1.1\"\nresolved \"https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791\"\n@@ -1176,6 +1190,10 @@ is-arrayish@^0.2.1:\nversion \"0.2.1\"\nresolved \"https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d\"\n+is-buffer@~1.1.1:\n+ version \"1.1.6\"\n+ resolved \"https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be\"\n+\nis-buffer@~2.0.3:\nversion \"2.0.4\"\nresolved \"https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623\"\n@@ -1535,6 +1553,14 @@ md5.js@^1.3.4:\ninherits \"^2.0.1\"\nsafe-buffer \"^5.1.2\"\n+md5@^2.1.0:\n+ version \"2.2.1\"\n+ resolved \"https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9\"\n+ dependencies:\n+ charenc \"~0.0.1\"\n+ crypt \"~0.0.1\"\n+ is-buffer \"~1.1.1\"\n+\nmerge-source-map@^1.1.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/merge-source-map/-/merge-source-map-1.1.0.tgz#2fdde7e6020939f70906a68f2d7ae685e4c8c646\"\n@@ -1578,12 +1604,22 @@ minimist@~0.0.1:\nversion \"0.0.10\"\nresolved \"https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf\"\[email protected], mkdirp@^0.5.0, mkdirp@^0.5.1:\[email protected], mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1:\nversion \"0.5.1\"\nresolved \"https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903\"\ndependencies:\nminimist \"0.0.8\"\n+mocha-junit-reporter@^1.23.1:\n+ version \"1.23.1\"\n+ resolved \"https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-1.23.1.tgz#ba11519c0b967f404e4123dd69bc4ba022ab0f12\"\n+ dependencies:\n+ debug \"^2.2.0\"\n+ md5 \"^2.1.0\"\n+ mkdirp \"~0.5.1\"\n+ strip-ansi \"^4.0.0\"\n+ xml \"^1.0.0\"\n+\nmocha@^6.2.2:\nversion \"6.2.2\"\nresolved \"https://registry.yarnpkg.com/mocha/-/mocha-6.2.2.tgz#5d8987e28940caf8957a7d7664b910dc5b2fea20\"\n@@ -1612,6 +1648,10 @@ mocha@^6.2.2:\nyargs-parser \"13.1.1\"\nyargs-unparser \"1.6.0\"\[email protected]:\n+ version \"2.0.0\"\n+ resolved \"https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8\"\n+\[email protected]:\nversion \"2.1.1\"\nresolved \"https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a\"\n@@ -2668,6 +2708,10 @@ [email protected]:\ndependencies:\nmkdirp \"^0.5.1\"\n+xml@^1.0.0:\n+ version \"1.0.1\"\n+ resolved \"https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5\"\n+\nxtend@^2.2.0:\nversion \"2.2.0\"\nresolved \"https://registry.yarnpkg.com/xtend/-/xtend-2.2.0.tgz#eef6b1f198c1c8deafad8b1765a04dad4a01c5a9\"\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: add and use CI targets from package.json
305,159
10.12.2019 11:19:59
-3,600
0d4f6e22b0f5e671467caee845e02ca9e8d8eb8b
chore: tune coverage reporting
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -60,10 +60,15 @@ jobs:\npaths:\n- ~/.cache/yarn\n- run:\n- name: Run tests and reports coverage to codecov\n- command: |\n- yarn coverage\n- yarn codecov\n- - store_artifacts: # upload test coverage as artifact\n- path: ./coverage/coverage.lcov\n- prefix: tests\n+ name: Runs tests with coverage\n+ command: yarn coverage\n+ - run:\n+ name: Report test results to codecov\n+ command: yarn codecov\n+ - store_artifacts:\n+ path: ./.nyc_output\n+ - store_artifacts:\n+ path: ./coverage\n+ # - store_artifacts: # upload test coverage as artifact\n+ # path: ./coverage/coverage.lcov\n+ # prefix: tests\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"scripts\": {\n\"build\": \"yarn run clean && NODE_ENV=production rollup -c\",\n\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n- \"clean\": \"rimraf dist build coverage .nyc_output doc *.lcov\",\n+ \"clean\": \"rimraf dist build coverage .nyc_output doc *.lcov reports\",\n\"codecov\": \"nyc report --reporter=text-lcov > coverage/coverage.lcov && codecov\",\n\"coverage\": \"nyc yarn run test:unit --exit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: tune coverage reporting
305,159
10.12.2019 12:47:33
-3,600
2ef94eea7f5f15967b1d4b33f22fb4fcec3949bf
chore: print yarn version in circle ci coverage
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -61,7 +61,9 @@ jobs:\n- ~/.cache/yarn\n- run:\nname: Runs tests with coverage\n- command: yarn coverage\n+ command: |\n+ yarn --version\n+ yarn coverage\n- run:\nname: Report test results to codecov\ncommand: yarn codecov\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: print yarn version in circle ci coverage
305,159
10.12.2019 13:02:54
-3,600
d9efe970d04e0be97badb2715ead584c27f4016c
fix: preair coverage reporting by using npm, workaround
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -67,10 +67,7 @@ jobs:\n- run:\nname: Report test results to codecov\ncommand: yarn codecov\n- - store_artifacts:\n- path: ./.nyc_output\n- store_artifacts:\npath: ./coverage\n- # - store_artifacts: # upload test coverage as artifact\n- # path: ./coverage/coverage.lcov\n- # prefix: tests\n+ # - store_artifacts:\n+ # path: ./.nyc_output\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n\"clean\": \"rimraf dist build coverage .nyc_output doc *.lcov reports\",\n\"codecov\": \"nyc report --reporter=text-lcov > coverage/coverage.lcov && codecov\",\n- \"coverage\": \"nyc yarn run test:unit --exit\",\n+ \"coverage\": \"nyc npm run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts'\",\n\"test:unit:ci\": \"yarn run test:unit --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: preair coverage reporting by using npm, workaround https://github.com/istanbuljs/nyc/issues/921
305,159
10.12.2019 13:17:18
-3,600
30fbd76d934ae58ab457b61eba5f08e6f7ac2c17
fix: repair coverage reporting, use npm to workaround
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "version: 2.1\n-workflows:\n- build:\n- jobs:\n- - unit-tests:\n- version: '12'\n- - coverage\n-\n-jobs:\n- unit-tests:\n- parameters:\n- version:\n- type: string\n- docker:\n- - image: circleci/node:<< parameters.version >>\n+commands:\n+ init-dependencies:\nsteps:\n- - checkout\n- restore_cache:\nname: Restore Yarn Package Cache\nkeys:\n@@ -28,7 +15,17 @@ jobs:\nkey: yarn-packages-{{ checksum \"yarn.lock\" }}\npaths:\n- ~/.cache/yarn\n- - run: mkdir reports\n+\n+jobs:\n+ unit-tests:\n+ parameters:\n+ version:\n+ type: string\n+ docker:\n+ - image: circleci/node:<< parameters.version >>\n+ steps:\n+ - checkout\n+ - init-dependencies\n- run:\nname: Run tests\ncommand: |\n@@ -47,18 +44,7 @@ jobs:\n- image: circleci/node:12\nsteps:\n- checkout\n- - restore_cache:\n- name: Restore Yarn Package Cache\n- keys:\n- - yarn-packages-{{ checksum \"yarn.lock\" }}\n- - run:\n- name: Install Dependencies\n- command: yarn install --frozen-lockfile\n- - save_cache:\n- name: Save Yarn Package Cache\n- key: yarn-packages-{{ checksum \"yarn.lock\" }}\n- paths:\n- - ~/.cache/yarn\n+ - init-dependencies\n- run:\nname: Runs tests with coverage\ncommand: |\n@@ -71,3 +57,10 @@ jobs:\npath: ./coverage\n# - store_artifacts:\n# path: ./.nyc_output\n+\n+workflows:\n+ build:\n+ jobs:\n+ - unit-tests:\n+ version: '12'\n+ - coverage\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"codecov\": \"nyc report --reporter=text-lcov > coverage/coverage.lcov && codecov\",\n\"coverage\": \"nyc npm run test:unit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n- \"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts'\",\n+ \"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --exit\",\n\"test:unit:ci\": \"yarn run test:unit --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml\",\n\"test:watch\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --watch-extensions ts --watch\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: repair coverage reporting, use npm to workaround https://github.com/istanbuljs/nyc/issues/921
305,159
10.12.2019 13:43:06
-3,600
3ec912d665a753c45216a14c9bcc9b6f366f20fa
feat: simplify point API
[ { "change_type": "MODIFY", "old_path": "src/Point.ts", "new_path": "src/Point.ts", "diff": "@@ -38,7 +38,7 @@ export default class Point {\n* @param value tag value\n* @return this\n*/\n- public addTag(name: string, value: string): Point {\n+ public tag(name: string, value: string): Point {\nthis.tags[name] = value\nreturn this\n}\n@@ -50,7 +50,7 @@ export default class Point {\n* @param value field value\n* @return this\n*/\n- public addBooleanField(name: string, value: boolean | any): Point {\n+ public booleanField(name: string, value: boolean | any): Point {\nthis.fields[name] = value ? 'T' : 'F'\nreturn this\n}\n@@ -62,7 +62,7 @@ export default class Point {\n* @param value field value\n* @return this\n*/\n- public addIntegerField(name: string, value: number | any): Point {\n+ public intField(name: string, value: number | any): Point {\nif (typeof value !== 'number') {\nlet val: number\nif (isNaN((val = parseInt(String(value))))) {\n@@ -83,7 +83,7 @@ export default class Point {\n* @param value field value\n* @return this\n*/\n- public addNumberField(name: string, value: number | any): Point {\n+ public floatField(name: string, value: number | any): Point {\nif (typeof value !== 'number') {\nlet val: number\nif (isNaN((val = parseFloat(value)))) {\n@@ -97,7 +97,7 @@ export default class Point {\nreturn this\n}\n- public addStringField(name: string, value: string | any): Point {\n+ public stringField(name: string, value: string | any): Point {\nif (value !== null && value !== undefined) {\nif (typeof value !== 'string') value = String(value)\nthis.fields[name] = escape.quoted(value)\n@@ -105,7 +105,7 @@ export default class Point {\nreturn this\n}\n- public setTime(value: string | undefined): Point {\n+ public timestamp(value: string | undefined): Point {\nthis.time = value\nreturn this\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -38,10 +38,8 @@ class WriteBuffer {\n}\n}\nflush(): Promise<void> {\n- if (this.message) {\n- const message = this.message\n- this.message = undefined\n- this.length = 0\n+ const message = this.reset()\n+ if (message) {\nreturn this.flushFn(message)\n} else {\nreturn Promise.resolve()\n" }, { "change_type": "MODIFY", "old_path": "test/unit/Point.test.ts", "new_path": "test/unit/Point.test.ts", "diff": "@@ -33,25 +33,25 @@ function createPoint(test: PointTest): Point {\n(field: [string, 'n' | 's' | 'b' | 'i', any]) => {\nswitch (field[1]) {\ncase 'n':\n- point.addNumberField(field[0], field[2])\n+ point.floatField(field[0], field[2])\nbreak\ncase 's':\n- point.addStringField(field[0], field[2])\n+ point.stringField(field[0], field[2])\nbreak\ncase 'b':\n- point.addBooleanField(field[0], field[2])\n+ point.booleanField(field[0], field[2])\nbreak\ncase 'i':\n- point.addIntegerField(field[0], field[2])\n+ point.intField(field[0], field[2])\nbreak\n}\n}\n)\n;(test.tags || []).forEach((tag: [string, string]) => {\n- point.addTag(tag[0], tag[1])\n+ point.tag(tag[0], tag[1])\n})\nif (test.time) {\n- point.setTime(test.time)\n+ point.timestamp(test.time)\n}\nreturn point\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -189,17 +189,18 @@ describe('WriteApiImpl', () => {\n.persist()\nsubject.writePoint(\nnew Point('test')\n- .addTag('t', ' ')\n- .addNumberField('value', 1)\n- .setTime('')\n+ .tag('t', ' ')\n+ .floatField('value', 1)\n+ .timestamp('')\n)\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\nexpect(logs.error).to.length(0)\nexpect(logs.warn).to.length(1)\nsubject.writePoints([\n- new Point('test').addNumberField('value', 2),\n- new Point('test').addNumberField('value', 3),\n- new Point('test').addNumberField('value', 4).setTime('1'),\n+ new Point('test'), // will be ignored\n+ new Point('test').floatField('value', 2),\n+ new Point('test').floatField('value', 3),\n+ new Point('test').floatField('value', 4).timestamp('1'),\n])\nawait new Promise(resolve => setTimeout(resolve, 10)) // wait for background flush and HTTP to finish\nexpect(logs.error).to.length(0)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: simplify point API
305,159
10.12.2019 14:11:44
-3,600
b6e5644132aeb1dfd99217f04d522d6b01ab17ee
feat: improve code coverage
[ { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -156,7 +156,8 @@ export class NodeHttpTransport implements Transport {\nres.on('aborted', () => {\nlisteners.error(new ResponseAbortedError())\n})\n- const statusCode = res.statusCode || 600\n+ const statusCode =\n+ res.statusCode || /* istanbul ignore next safety check */ 600\nif (statusCode >= 300) {\nlet body = ''\nres.on('data', s => {\n@@ -189,6 +190,7 @@ export class NodeHttpTransport implements Transport {\n})\n// Support older Nodes which don't allow .timeout() in the\n// request options\n+ /* istanbul ignore else support older node versions */\nif (typeof req.setTimeout === 'function') {\nreq.setTimeout(requestMessage.timeout)\n}\n@@ -201,6 +203,7 @@ export class NodeHttpTransport implements Transport {\n})\nreq.on('close', listeners.complete)\n+ /* istanbul ignore else support older node versions */\nif (requestMessage.body) {\nreq.write(requestMessage.body)\n}\n@@ -230,17 +233,20 @@ export class NodeHttpTransport implements Transport {\ngetRetryDelay(error, this.retryJitter)\n)\ncancellable.addCancelableAction(() => {\n+ /* istanbul ignore next safety check */\nif (callbacks.complete) callbacks.complete()\nclearTimeout(cancelHandle)\n})\nreturn\n}\n}\n+ /* istanbul ignore else safety check */\nif (callbacks.error) callbacks.error(error)\n},\ncomplete: (): void => {\nif (state === 0) {\nstate = 2\n+ /* istanbul ignore else safety check */\nif (callbacks.complete) callbacks.complete()\n}\n},\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -174,6 +174,16 @@ describe('NodeHttpTransport', () => {\ntimeout: 100,\nmaxRetries: 0,\n}\n+ it(`fails silently on server error`, async () => {\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply(500, 'not ok')\n+ expect(\n+ new NodeHttpTransport(transportOptions).send('/test', '', {\n+ method: 'GET',\n+ })\n+ ).to.not.throw\n+ })\nit(`fails on server error`, async () => {\nnock(transportOptions.url)\n.get('/test')\n" }, { "change_type": "MODIFY", "old_path": "tsconfig.json", "new_path": "tsconfig.json", "diff": "\"allowJs\": false,\n\"declaration\": true,\n\"outDir\": \"./dist\",\n- \"removeComments\": true,\n+ \"removeComments\": false,\n\"strict\": true,\n\"strictPropertyInitialization\": false,\n\"noUnusedLocals\": true,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: improve code coverage
305,159
10.12.2019 14:16:26
-3,600
81dc9189806aa2dd768dbe65047e22c1f7e284fb
fix: improve coverage of errors
[ { "change_type": "MODIFY", "old_path": "src/errors.ts", "new_path": "src/errors.ts", "diff": "@@ -12,6 +12,7 @@ export function isStatusCodeRetriable(statusCode: number): boolean {\n}\nexport class IllegalArgumentError extends Error {\n+ /* istanbul ignore next */\nconstructor(message: string) {\nsuper(message)\nObject.setPrototypeOf(this, IllegalArgumentError.prototype)\n@@ -24,6 +25,7 @@ export class IllegalArgumentError extends Error {\nexport class HttpError extends Error implements RetriableDecision {\nprivate _retryAfter: number\n+ /* istanbul ignore next */\nconstructor(\nreadonly statusCode: number,\nreadonly statusMessage: string | undefined,\n@@ -37,6 +39,10 @@ export class HttpError extends Error implements RetriableDecision {\n} else {\nthis.message = `${statusCode} ${statusMessage}`\n}\n+ this.setRetryAfter(retryAfter)\n+ }\n+\n+ private setRetryAfter(retryAfter?: string | undefined) {\nif (typeof retryAfter === 'string') {\n// try to parse the supplied number as milliseconds\nthis._retryAfter = parseInt(retryAfter)\n@@ -98,6 +104,7 @@ export function getRetryDelay(error: Error, retryJitter: number): number {\n}\nexport class RequestTimedOutError extends Error implements RetriableDecision {\n+ /* istanbul ignore next */\nconstructor() {\nsuper()\nObject.setPrototypeOf(this, RequestTimedOutError.prototype)\n@@ -112,6 +119,7 @@ export class RequestTimedOutError extends Error implements RetriableDecision {\n}\nexport class ResponseAbortedError extends Error implements RetriableDecision {\n+ /* istanbul ignore next */\nconstructor() {\nsuper()\nObject.setPrototypeOf(this, ResponseAbortedError.prototype)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: improve coverage of errors
305,159
10.12.2019 14:18:53
-3,600
1012242c6d35a49784eb0c5e0e58f8d0f0cc4844
fix: improve coverage of WriteApiImpl
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -135,6 +135,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nconst scheduleNextSend = (): void => {\nif (writeOptions.flushInterval > 0) {\nthis._clearFlushTimeout()\n+ /* istanbul ignore else manually reviewed, hard to reproduce */\nif (!this.closed) {\nthis._timeoutHandle = setTimeout(\n() =>\n@@ -166,6 +167,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\nprivate _scheduleRetry(fn: () => any, delay: number): void {\n+ /* istanbul ignore else manually reviewed, hard to reproduce */\nif (!this.closed) {\n// TODO monitor and limit retries, cancel them on close\nsetTimeout(fn, delay)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: improve coverage of WriteApiImpl
305,159
11.12.2019 09:00:32
-3,600
dd98dc829abd9d3fc59945c4a5089a40e980eea1
feat(errors): improve tests for errors
[ { "change_type": "MODIFY", "old_path": "src/errors.ts", "new_path": "src/errors.ts", "diff": "@@ -25,7 +25,7 @@ export class IllegalArgumentError extends Error {\nexport class HttpError extends Error implements RetriableDecision {\nprivate _retryAfter: number\n- /* istanbul ignore next */\n+ /* istanbul ignore next because of super() not being covered*/\nconstructor(\nreadonly statusCode: number,\nreadonly statusMessage: string | undefined,\n@@ -45,10 +45,14 @@ export class HttpError extends Error implements RetriableDecision {\nprivate setRetryAfter(retryAfter?: string | undefined) {\nif (typeof retryAfter === 'string') {\n// try to parse the supplied number as milliseconds\n+ if (/^[0-9]+$/.test(retryAfter)) {\nthis._retryAfter = parseInt(retryAfter)\n} else {\nthis._retryAfter = -1\n}\n+ } else {\n+ this._retryAfter = -1\n+ }\n}\ncanRetry(): boolean {\n@@ -104,7 +108,7 @@ export function getRetryDelay(error: Error, retryJitter: number): number {\n}\nexport class RequestTimedOutError extends Error implements RetriableDecision {\n- /* istanbul ignore next */\n+ /* istanbul ignore next because of super() not being covered */\nconstructor() {\nsuper()\nObject.setPrototypeOf(this, RequestTimedOutError.prototype)\n@@ -119,7 +123,7 @@ export class RequestTimedOutError extends Error implements RetriableDecision {\n}\nexport class ResponseAbortedError extends Error implements RetriableDecision {\n- /* istanbul ignore next */\n+ /* istanbul ignore next because of super() not being covered */\nconstructor() {\nsuper()\nObject.setPrototypeOf(this, ResponseAbortedError.prototype)\n" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "@@ -16,7 +16,7 @@ describe('errors', () => {\nnew HttpError(429, 'Too Many Requests'),\nnew RequestTimedOutError(),\nnew ResponseAbortedError(),\n- new HttpError(429, 'Too Many Requests'),\n+ new HttpError(429, 'Too Many Requests', '', '2019-11-02'),\n(() => {\nconst err = new Error('Connection reset')\n;(err as any).code = 'ECONNRESET'\n@@ -26,6 +26,9 @@ describe('errors', () => {\ntestSetOK.forEach(error => {\nit('retries ' + error, () => {\nexpect(canRetryHttpCall(error)).to.be.true\n+ if (error instanceof HttpError) {\n+ expect(error.retryAfter()).to.be.equal(-1)\n+ }\n})\n})\nconst testSetNotOK = [\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(errors): improve tests for errors
305,159
11.12.2019 09:09:56
-3,600
7ac8cf7a13804b718272239995c0ecdc1b6eb4cd
feat: change iface to use ArrayLike
[ { "change_type": "MODIFY", "old_path": "src/WriteApi.ts", "new_path": "src/WriteApi.ts", "diff": "@@ -40,7 +40,7 @@ export default interface WriteApi {\n*\n* @param records lines in InfluxDB Line Protocol\n*/\n- writePoints(points: Array<Point>): void\n+ writePoints(points: ArrayLike<Point>): void\n/**\n* Flushes pending writes to the server.\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -177,7 +177,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nwriteRecord(record: string): void {\nthis.buffer.add(record)\n}\n- writeRecords(records: string[]): void {\n+ writeRecords(records: ArrayLike<string>): void {\nfor (let i = 0; i < records.length; i++) {\nthis.buffer.add(records[i])\n}\n@@ -186,7 +186,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nconst line = point.toLineProtocol(this)\nif (line) this.buffer.add(line)\n}\n- writePoints(points: Point[]): void {\n+ writePoints(points: ArrayLike<Point>): void {\nfor (let i = 0; i < points.length; i++) {\nthis.writePoint(points[i])\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: change iface to use ArrayLike
305,159
11.12.2019 09:37:18
-3,600
77d561c261448747f17582f5d6404efd2b433595
feat: generate API documentation
[ { "change_type": "MODIFY", "old_path": ".circleci/config.yml", "new_path": ".circleci/config.yml", "diff": "@@ -31,6 +31,7 @@ jobs:\ncommand: |\nyarn test:unit:ci\nyarn lint:ci\n+ yarn typedoc\n# Upload results\n- store_test_results:\npath: reports\n@@ -38,6 +39,8 @@ jobs:\npath: ./reports/mocha/test-results.xml\n- store_artifacts:\npath: ./reports/eslint/eslint.xml\n+ - store_artifacts:\n+ path: ./reports/apidoc\ncoverage:\nparameters:\ndocker:\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"test:unit:ci\": \"yarn run test:unit --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml\",\n\"test:watch\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --watch-extensions ts --watch\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n+ \"typedoc\": \"typedoc --excludePrivate --mode file --out ./reports/apidoc --target es6 --moduleResolution node --tsconfig ./tsconfig.doc.json ./src\",\n\"lint\": \"eslint 'src/**/*.ts'\",\n\"lint:ci\": \"yarn run lint --format junit --output-file reports/eslint/eslint.xml\",\n\"lint:fix\": \"eslint --fix 'src/**/*.ts'\"\n" }, { "change_type": "MODIFY", "old_path": "src/impl/Logger.ts", "new_path": "src/impl/Logger.ts", "diff": "@@ -19,7 +19,7 @@ export const consoleLogger: Logger = Object.freeze({\n})\nlet provider: Logger = consoleLogger\n-const instance: Logger = {\n+const Logger: Logger = {\nerror(message, error) {\nprovider.error(message, error)\n},\n@@ -39,4 +39,4 @@ export function setLogger(logger: Logger): Logger {\nreturn previous\n}\n-export default instance\n+export default Logger\n" }, { "change_type": "ADD", "old_path": null, "new_path": "tsconfig.doc.json", "diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"resolveJsonModule\": false\n+ },\n+ \"include\": [\"src/**/*.ts\"]\n+}\n" }, { "change_type": "MODIFY", "old_path": "tsconfig.json", "new_path": "tsconfig.json", "diff": "{\n\"compilerOptions\": {\n- \"target\": \"es5\",\n+ \"target\": \"es2015\",\n\"lib\": [\"es2015\", \"es2017\"],\n\"allowJs\": false,\n\"declaration\": true,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: generate API documentation
305,159
11.12.2019 09:50:38
-3,600
f5ed57df787d0b97ad625480bde39bd2c2d163c0
chore: tune generator of api documentation
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"test:unit:ci\": \"yarn run test:unit --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml\",\n\"test:watch\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --watch-extensions ts --watch\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n- \"typedoc\": \"typedoc --excludePrivate --mode file --out ./reports/apidoc --target es6 --moduleResolution node --tsconfig ./tsconfig.doc.json ./src\",\n+ \"typedoc\": \"typedoc --excludePrivate --excludeNotExported --mode file --out ./reports/apidoc --target es6 --tsconfig ./tsconfig.doc.json ./src\",\n\"lint\": \"eslint 'src/**/*.ts'\",\n\"lint:ci\": \"yarn run lint --format junit --output-file reports/eslint/eslint.xml\",\n\"lint:fix\": \"eslint --fix 'src/**/*.ts'\"\n" }, { "change_type": "MODIFY", "old_path": "src/InfluxDB.ts", "new_path": "src/InfluxDB.ts", "diff": "@@ -38,7 +38,15 @@ export default class InfluxDB {\nprivate transport: Transport\n/* eslint-disable no-dupe-class-members */\n+ /**\n+ * Creates influxdb client from a string URL\n+ * @param url influxDB url, such as http://localhost:9999?token=my-token\n+ */\nconstructor(url: string)\n+ /**\n+ * Creates influxdb client options from an options object.\n+ * @param options options\n+ */\nconstructor(options: ClientOptions)\nconstructor(options?: any) {\n@@ -54,8 +62,8 @@ export default class InfluxDB {\nthrow new IllegalArgumentError('No token specified!')\nthis.transport = createTransport(this._options)\n}\n-\n/* eslint-enable no-dupe-class-members */\n+\ngetWriteApi(\norg: string,\nbucket: string,\n" }, { "change_type": "MODIFY", "old_path": "src/options.ts", "new_path": "src/options.ts", "diff": "@@ -21,6 +21,9 @@ export const DEFAULT_ConnectionOptions: Partial<ConnectionOptions> = {\nretryJitter: 1000,\n}\n+/**\n+ * Options used by [[WriteApi]]\n+ */\nexport interface WriteOptions {\n/** max number of records to send in a batch */\nbatchSize: number\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: tune generator of api documentation
305,159
11.12.2019 11:20:43
-3,600
deaabfa0f7f4f4b2128b2d65c5be6c77ae49a67f
feat: change observer to be a multi-purpose interface
[ { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -88,7 +88,7 @@ export class NodeHttpTransport implements Transport {\npath: string,\nbody: string,\noptions: SendOptions,\n- callbacks?: Partial<CommunicationObserver>\n+ callbacks?: Partial<CommunicationObserver<any>>\n): void {\nconst message = this.createRequestMessage(path, body, options)\nconst cancellable = new CancellableImpl()\n@@ -136,7 +136,7 @@ export class NodeHttpTransport implements Transport {\nprivate request(\nrequestMessage: {[key: string]: any},\ncancellable: CancellableImpl,\n- callbacks?: Partial<CommunicationObserver>\n+ callbacks?: Partial<CommunicationObserver<any>>\n): void {\nconst listeners = this.createRetriableCallbacks(\nrequestMessage,\n@@ -213,8 +213,8 @@ export class NodeHttpTransport implements Transport {\nprivate createRetriableCallbacks(\nrequestMessage: {[key: string]: any},\ncancellable: CancellableImpl,\n- callbacks: Partial<CommunicationObserver> = {}\n- ): CommunicationObserver {\n+ callbacks: Partial<CommunicationObserver<any>> = {}\n+ ): CommunicationObserver<any> {\nlet state = 0\nconst retVal = {\nnext: (data: any): void => {\n" }, { "change_type": "MODIFY", "old_path": "src/transport.ts", "new_path": "src/transport.ts", "diff": "@@ -15,13 +15,13 @@ export interface Cancellable {\n}\n/**\n- * Let use observe change in the communication.\n+ * Observes communication with the server.\n*/\n-export interface CommunicationObserver {\n+export interface CommunicationObserver<T> {\n/**\n* Data chunk received, can be called mupliple times.\n*/\n- next(data: any): void\n+ next(data: T): void\n/**\n* Communication ended with an error.\n*/\n@@ -55,12 +55,12 @@ export interface Transport {\n* @param path HTTP path\n* @param body message body\n* @param options send options\n- * @param callbacks communication callbacks\n+ * @param callbacks communication callbacks with chunks of any type\n*/\nsend(\npath: string,\nbody: string,\noptions?: Partial<SendOptions>,\n- callbacks?: Partial<CommunicationObserver>\n+ callbacks?: Partial<CommunicationObserver<any>>\n): void\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: change observer to be a multi-purpose interface
305,159
11.12.2019 12:50:17
-3,600
8c843723924efd11f4178d177c44690bf7908b05
feat: change default content type to application/json
[ { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -118,7 +118,7 @@ export class NodeHttpTransport implements Transport {\npath,\nmethod: sendOptions.method,\nheaders: {\n- 'content-type': 'text/plain; charset=utf-8',\n+ 'content-type': 'application/json; charset=utf-8',\n...sendOptions.headers,\n},\nbody: bodyBuffer,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: change default content type to application/json
305,159
11.12.2019 13:10:39
-3,600
ff58e6dbf773dad36e171c16f64223e224692542
chire: change package name
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n- \"name\": \"influxdb-client\",\n+ \"name\": \"@influxdata/influxdb2-client\",\n\"version\": \"0.0.1\",\n- \"description\": \"InfluxDB client\",\n+ \"description\": \"InfluxDB 2.0 client\",\n\"main\": \"dist/index.js\",\n\"module\": \"dist/index.mjs\",\n\"scripts\": {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chire: change package name
305,159
11.12.2019 13:11:27
-3,600
8a483af901ecfab0bb9b8e259604af7b11b7731f
use api/v2 prefix
[ { "change_type": "MODIFY", "old_path": "src/WriteApi.ts", "new_path": "src/WriteApi.ts", "diff": "import Point from './Point'\n/**\n- * The asynchronous non-blocking API to Write time-series data into InfluxDB 2.0.\n+ * The asynchronous buffering API to Write time-series data into InfluxDB 2.0.\n* <p>\n* The data are formatted in <a href=\"https://bit.ly/2QL99fu\">Line Protocol</a>.\n* <p>\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -69,7 +69,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nprecision: WritePrecission,\nclientOptions: ClientOptions\n) {\n- const httpPath = `/write?org=${encodeURIComponent(\n+ const httpPath = `/api/v2/write?org=${encodeURIComponent(\norg\n)}&bucket=${encodeURIComponent(bucket)}&precission=${precision}`\nconst writeOptions = {\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -22,7 +22,7 @@ const ORG = 'org'\nconst BUCKET = 'bucket'\nconst PRECISSION = WritePrecission.s\n-const WRITE_PATH_NS = `/write?org=${ORG}&bucket=${BUCKET}&precission=ns`\n+const WRITE_PATH_NS = `/api/v2/write?org=${ORG}&bucket=${BUCKET}&precission=ns`\ndescribe('WriteApiImpl', () => {\nbeforeEach(() => {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
use api/v2 prefix
305,159
11.12.2019 15:59:40
-3,600
d2c270dee98c4e7c5552a75bf9f594d81d9e4136
feat: add line splitter from Buffer chunks
[ { "change_type": "ADD", "old_path": null, "new_path": "src/impl/ChunksToLines.ts", "diff": "+import {CommunicationObserver, Cancellable} from '../transport'\n+import {Buffer} from 'buffer'\n+/**\n+ * Receives data in chunks and fires just lines\n+ */\n+export default class ChunksToLines implements CommunicationObserver<any> {\n+ previous?: Buffer\n+ finished = false\n+\n+ constructor(private target: CommunicationObserver<string>) {}\n+\n+ next(chunk: any): void {\n+ if (this.finished) return\n+ if (Buffer.isBuffer(chunk)) {\n+ this.bufferReceived(chunk)\n+ } else {\n+ this.error(new Error('Only node buffer chunks are supported!'))\n+ }\n+ }\n+ error(error: Error): void {\n+ if (!this.finished) {\n+ this.finished = true\n+ this.target.error(error)\n+ }\n+ }\n+ complete(): void {\n+ if (!this.finished) {\n+ if (this.previous) {\n+ this.target.next(this.previous.toString('utf8'))\n+ }\n+ this.finished = true\n+ this.target.complete()\n+ }\n+ }\n+ useCancellable(cancellable: Cancellable): void {\n+ this.target.useCancellable && this.target.useCancellable(cancellable)\n+ }\n+\n+ private bufferReceived(chunk: Buffer): void {\n+ let index: number\n+ let start = 0\n+ if (this.previous) {\n+ chunk = Buffer.concat([this.previous as Buffer, chunk])\n+ index = (this.previous as Buffer).length\n+ } else {\n+ index = 0\n+ }\n+ let quoted = false\n+ while (index < chunk.length) {\n+ const c = chunk.readInt8(index)\n+ if (c === 10) {\n+ if (!quoted) {\n+ /* do not emit CR+LR or LF line ending */\n+ const end =\n+ index > 0 && chunk.readInt8(index - 1) === 13 ? index - 1 : index\n+ this.target.next(chunk.toString('utf8', start, end))\n+ start = index + 1\n+ }\n+ } else if (c === 34 /* \" */) {\n+ quoted = !quoted\n+ }\n+ index++\n+ }\n+ if (start < index) {\n+ this.previous = Buffer.allocUnsafe(index - start)\n+ chunk.copy(this.previous, 0, start, index)\n+ } else {\n+ this.previous = undefined\n+ }\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/fixture/chunksToLinesTables.json", "diff": "+[\n+ {\n+ \"name\": \"1 chunk, one line\",\n+ \"chunks\": [\"abdc, efg\"],\n+ \"lines\": [\"abdc, efg\"],\n+ \"withCancellable\": true\n+ },\n+ {\n+ \"name\": \"1 chunk, two lines lf-terminated\",\n+ \"chunks\": [\"abdc\\nefg\\n\"],\n+ \"lines\": [\"abdc\", \"efg\"]\n+ },\n+ {\n+ \"name\": \"1 chunk, two lines cr+lf-terminated\",\n+ \"chunks\": [\"abdc\\r\\nefg\\r\\n\"],\n+ \"lines\": [\"abdc\", \"efg\"]\n+ },\n+ {\n+ \"name\": \"1 chunk, one line with escaped new line\",\n+ \"chunks\": [\"\\\"ab\\\"\\\"dc\\\",\\\"\\nefg\\\"\"],\n+ \"lines\": [\"\\\"ab\\\"\\\"dc\\\",\\\"\\nefg\\\"\"]\n+ },\n+ {\n+ \"name\": \"2 chunks, 3 lines\",\n+ \"chunks\": [\"ab\\ncd\\nef\", \"gh\"],\n+ \"lines\": [\"ab\", \"cd\", \"efgh\"]\n+ },\n+ {\n+ \"name\": \"2 chunks, error after 1st chunk\",\n+ \"chunks\": [\"ab\\ncd\", \"error\", \"ef\"],\n+ \"lines\": [\"ab\"]\n+ }\n+]\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/impl/ChunksToLines.test.ts", "diff": "+import {expect} from 'chai'\n+import ChunksToLines from '../../../src/impl/ChunksToLines'\n+import chunksToLinesTables from '../../fixture/chunksToLinesTables.json'\n+import {CommunicationObserver, Cancellable} from '../../../src/transport'\n+import sinon from 'sinon'\n+\n+interface ChunkTest {\n+ name: string\n+ chunks: string[]\n+ lines: string[]\n+ withCancellable?: boolean // use observer with cancellable implementation\n+}\n+\n+class CollectLinesObserver implements CommunicationObserver<string> {\n+ lines: string[] = []\n+ completed = 0\n+ failed = 0\n+ cancellableSet = false\n+\n+ next(data: string): void {\n+ this.lines.push(data)\n+ }\n+ error(error: Error): void {\n+ this.failed++\n+ }\n+ complete(): void {\n+ this.completed++\n+ }\n+}\n+\n+class CollectLinesObserver2 extends CollectLinesObserver {\n+ useCancellable(cancellable: Cancellable): void {\n+ this.cancellableSet = true\n+ }\n+}\n+\n+describe('ChunksToLines', () => {\n+ ;(chunksToLinesTables as Array<ChunkTest>).forEach((test: ChunkTest) => {\n+ it(`creates correct lines from test set '${test.name}'`, () => {\n+ const target = test.withCancellable\n+ ? new CollectLinesObserver2()\n+ : new CollectLinesObserver()\n+ const subject = new ChunksToLines(target)\n+ subject.useCancellable({isCancelled: sinon.mock(), cancel: sinon.mock()})\n+ let failed = false\n+ for (let i = 0; i < test.chunks.length; i++) {\n+ const chunk = test.chunks[i]\n+ if (chunk === 'error') {\n+ failed = true\n+ subject.error(new Error())\n+ } else {\n+ subject.next(Buffer.from(chunk, 'utf8'))\n+ if (failed) {\n+ subject.error(new Error())\n+ }\n+ }\n+ }\n+ subject.complete()\n+ expect(test.lines).to.deep.equal(target.lines)\n+ expect(target.cancellableSet).to.equal(!!test.withCancellable)\n+ expect(target.failed).to.equal(failed ? 1 : 0)\n+ expect(target.completed).to.equal(failed ? 0 : 1)\n+ })\n+ })\n+ it('fails on unsupported data', () => {\n+ const target = new CollectLinesObserver()\n+ const subject = new ChunksToLines(target)\n+ subject.next(1)\n+ expect(target.failed).to.be.equal(1)\n+ })\n+})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add line splitter from Buffer chunks
305,159
11.12.2019 18:04:40
-3,600
2f9a1134b6be32dacd84eef5ac1a4bb2659d544c
feat: add query api with simple raw query
[ { "change_type": "MODIFY", "old_path": "src/InfluxDB.ts", "new_path": "src/InfluxDB.ts", "diff": "@@ -5,6 +5,8 @@ import {parse} from 'url'\nimport {IllegalArgumentError} from './errors'\nimport {Transport} from './transport'\nimport NodeHttpTransport from './impl/NodeHttpTransport'\n+import QueryApi from './QueryApi'\n+import QueryApiImpl from './impl/QueryApiImpl'\n/**\n* Fills URL out into into a IClusterConfig object\n@@ -64,6 +66,13 @@ export default class InfluxDB {\n}\n/* eslint-enable no-dupe-class-members */\n+ /**\n+ * Creates [[WriteApi]] for the supplied organization and bucket.\n+ *\n+ * @param org Specifies the destination organization for writes. Takes either the ID or Name interchangeably.\n+ * @param bucket The destination bucket for writes.\n+ * @param precission Timestamp precision for line items.\n+ */\ngetWriteApi(\norg: string,\nbucket: string,\n@@ -77,4 +86,14 @@ export default class InfluxDB {\nthis._options\n)\n}\n+\n+ /**\n+ * Creates [[QueryAPI]] for the supplied organization .\n+ *\n+ * @param org Specifies the organization for queries.\n+ * @return query api instance\n+ */\n+ getQueryApi(org: string): QueryApi {\n+ return new QueryApiImpl(this.transport, org)\n+ }\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/QueryApi.ts", "diff": "+import {CommunicationObserver} from './transport'\n+\n+export interface QueryOptions {\n+ /**\n+ * Specifies the name of the organization executing the query. Takes either the ID or Name interchangeably.\n+ */\n+ org: string\n+ /**\n+ * Type of the query, default is \"flux\"\n+ */\n+ type?: 'influxql' | 'flux'\n+ /**\n+ * Required only for \"influxql\" queries.\n+ */\n+ cluster?: string\n+ /**\n+ * Required only for \"influxql\" queries.\n+ */\n+ db?: string\n+ /**\n+ * Required only for \"influxql\" queries.\n+ */\n+ rp?: string\n+}\n+\n+/**\n+ * Query InfluxDB 2.0.\n+ */\n+export default interface QueryApi {\n+ /**\n+ * Adds extra options for this query API.\n+ * @param options\n+ * @return this\n+ */\n+ with(options: Partial<QueryOptions>): QueryApi\n+\n+ /**\n+ * Executes the query and asynchronously stream all result lines to consumer.\n+ * @param record single line in the query result\n+ */\n+ queryRaw(query: string, consumer: CommunicationObserver<string>): void\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/impl/QueryApiImpl.ts", "diff": "+import QueryApi, {QueryOptions} from '../QueryApi'\n+import {Transport, CommunicationObserver} from '../transport'\n+import ChunksToLines from './ChunksToLines'\n+\n+const DEFAULT_dialect: any = {\n+ header: true,\n+ delimiter: ',',\n+ quoteChar: '\"',\n+ commentPrefix: '#',\n+ annotations: ['datatype', 'group', 'default'],\n+}\n+\n+export class QueryApiImpl implements QueryApi {\n+ private options: QueryOptions\n+ constructor(private transport: Transport, org: string) {\n+ this.options = {org}\n+ }\n+\n+ with(options: Partial<QueryOptions>): QueryApi {\n+ this.options = {...this.options, ...options}\n+ return this\n+ }\n+\n+ queryRaw(query: string, consumer: CommunicationObserver<string>): void {\n+ this.transport.send(\n+ `/api/v2/query?org=${encodeURIComponent(this.options.org)}`,\n+ JSON.stringify({\n+ query,\n+ dialect: DEFAULT_dialect,\n+ type: this.options.type,\n+ }),\n+ {\n+ method: 'POST',\n+ headers: {\n+ 'content-type': 'application/json; encoding=utf-8',\n+ },\n+ },\n+ new ChunksToLines(consumer)\n+ )\n+ }\n+}\n+\n+export default QueryApiImpl\n" }, { "change_type": "MODIFY", "old_path": "src/index.ts", "new_path": "src/index.ts", "diff": "@@ -3,5 +3,6 @@ export * from './errors'\nexport * from './util/escape'\nexport * from './util/currentTime'\nexport {default as Point} from './Point'\n+export {default as QueryApi} from './QueryApi'\nexport {default as WriteApi} from './WriteApi'\nexport {default as InfluxDB} from './InfluxDB'\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/fixture/query/simpleResponse.txt", "diff": "+,result,table,_start,_stop,_time,_value,_field,_measurement,location\n+,_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:15.995033574Z,55,value,temperature,west\n+,_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,55,value,temperature,west\n+\n+,result,table,_start,_stop,_time,_value,_field,_measurement,location\n+,_result,1,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,\"a,b,\n+,c\",text,temperature,west\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/fixture/query/simpleResponseLines.json", "diff": "+[\n+ \",result,table,_start,_stop,_time,_value,_field,_measurement,location\",\n+ \",_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:15.995033574Z,55,value,temperature,west\",\n+ \",_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,55,value,temperature,west\",\n+ \"\",\n+ \",result,table,_start,_stop,_time,_value,_field,_measurement,location\",\n+ \",_result,1,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,\\\"a,b,\\n,c\\\",text,temperature,west\"\n+]\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/QueryApi.test.ts", "diff": "+import {expect} from 'chai'\n+import nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\n+import {InfluxDB, ClientOptions} from '../../src'\n+import fs from 'fs'\n+import {CollectLinesObserver} from './util/CollectLinesObserver'\n+import simpleResponseLines from '../fixture/query/simpleResponseLines.json'\n+\n+const ORG = `my-org`\n+const QUERY_PATH = `/api/v2/query?org=${ORG}`\n+\n+const clientOptions: ClientOptions = {\n+ url: 'http://fake:9999',\n+ token: 'a',\n+ retryJitter: 0, // no retries for tests\n+ maxRetries: 0,\n+}\n+\n+describe('QueryApi', () => {\n+ beforeEach(() => {\n+ nock.disableNetConnect()\n+ })\n+ afterEach(() => {\n+ nock.cleanAll()\n+ nock.enableNetConnect()\n+ })\n+ it('runs raw query', async () => {\n+ const subject = new InfluxDB(clientOptions).getQueryApi(ORG).with({})\n+ nock(clientOptions.url)\n+ .post(QUERY_PATH)\n+ .reply((_uri, _requestBody) => {\n+ return [\n+ 200,\n+ fs.createReadStream('test/fixture/query/simpleResponse.txt'),\n+ {'retry-after': '1'},\n+ ]\n+ })\n+ .persist()\n+ const target = new CollectLinesObserver()\n+ await new Promise((resolve, reject) =>\n+ subject.queryRaw(\n+ 'from(bucket:\"my-bucket\") |> range(start: 0)',\n+ target.attach(resolve, reject)\n+ )\n+ )\n+ expect(target.completed).to.equals(1)\n+ expect(target.lines).to.deep.equal(simpleResponseLines)\n+ })\n+})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/ChunksToLines.test.ts", "new_path": "test/unit/impl/ChunksToLines.test.ts", "diff": "import {expect} from 'chai'\nimport ChunksToLines from '../../../src/impl/ChunksToLines'\nimport chunksToLinesTables from '../../fixture/chunksToLinesTables.json'\n-import {CommunicationObserver, Cancellable} from '../../../src/transport'\n+import {Cancellable} from '../../../src/transport'\nimport sinon from 'sinon'\n+import {CollectLinesObserver} from '../util/CollectLinesObserver'\ninterface ChunkTest {\nname: string\n@@ -11,23 +12,6 @@ interface ChunkTest {\nwithCancellable?: boolean // use observer with cancellable implementation\n}\n-class CollectLinesObserver implements CommunicationObserver<string> {\n- lines: string[] = []\n- completed = 0\n- failed = 0\n- cancellableSet = false\n-\n- next(data: string): void {\n- this.lines.push(data)\n- }\n- error(error: Error): void {\n- this.failed++\n- }\n- complete(): void {\n- this.completed++\n- }\n-}\n-\nclass CollectLinesObserver2 extends CollectLinesObserver {\nuseCancellable(cancellable: Cancellable): void {\nthis.cancellableSet = true\n" }, { "change_type": "MODIFY", "old_path": "test/unit/influxdb.test.ts", "new_path": "test/unit/influxdb.test.ts", "diff": "@@ -64,9 +64,14 @@ describe('influxdb', () => {\n})\ndescribe('apis', () => {\nconst influxDb = new InfluxDB('http://localhost:9999?token=a')\n- it('writeApi can be obtained without a pending schedule', () => {\n+ it('serves queryApi writeApi without a pending schedule', () => {\nexpect(influxDb.getWriteApi('org', 'bucket')).to.be.ok\nexpect(influxDb.getWriteApi('org', 'bucket', WritePrecission.s)).to.be.ok\n})\n+ it('serves queryApi', () => {\n+ expect(influxDb.getQueryApi('my-org') as any)\n+ .property('options')\n+ .to.deep.equals({org: 'my-org'})\n+ })\n})\n})\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/util/CollectLinesObserver.ts", "diff": "+import {CommunicationObserver} from '../../../src/transport'\n+\n+export class CollectLinesObserver implements CommunicationObserver<string> {\n+ lines: string[] = []\n+ completed = 0\n+ failed = 0\n+ cancellableSet = false\n+ resolve?: (value?: void) => void\n+ reject?: (reason?: any) => void\n+\n+ next(data: string): void {\n+ this.lines.push(data)\n+ }\n+ error(error: Error): void {\n+ this.failed++\n+ if (this.reject) this.reject(error)\n+ }\n+ complete(): void {\n+ this.completed++\n+ if (this.resolve) this.resolve()\n+ }\n+\n+ attach(\n+ resolve?: (value?: void) => void,\n+ reject?: (reason?: any) => void\n+ ): CollectLinesObserver {\n+ this.resolve = resolve\n+ this.reject = reject\n+ return this\n+ }\n+}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add query api with simple raw query
305,159
12.12.2019 08:14:23
-3,600
83dcaa5a5fb6cce2cbb551d1b346fd539d2425a9
fix: access buffer as uint8 array
[ { "change_type": "MODIFY", "old_path": "src/impl/ChunksToLines.ts", "new_path": "src/impl/ChunksToLines.ts", "diff": "@@ -47,12 +47,11 @@ export default class ChunksToLines implements CommunicationObserver<any> {\n}\nlet quoted = false\nwhile (index < chunk.length) {\n- const c = chunk.readInt8(index)\n+ const c = chunk[index]\nif (c === 10) {\nif (!quoted) {\n/* do not emit CR+LR or LF line ending */\n- const end =\n- index > 0 && chunk.readInt8(index - 1) === 13 ? index - 1 : index\n+ const end = index > 0 && chunk[index - 1] === 13 ? index - 1 : index\nthis.target.next(chunk.toString('utf8', start, end))\nstart = index + 1\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: access buffer as uint8 array
305,159
12.12.2019 11:23:21
-3,600
ff124cdd1687c199610c0c851e22ea95b1909132
chore: use query samples with annotation lines
[ { "change_type": "MODIFY", "old_path": "test/fixture/query/simpleResponse.txt", "new_path": "test/fixture/query/simpleResponse.txt", "diff": "+#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string\n+#group,false,false,true,true,false,false,true,true,true\n+#default,_result,,,,,,,,\n,result,table,_start,_stop,_time,_value,_field,_measurement,location\n-,_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:15.995033574Z,55,value,temperature,west\n-,_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,55,value,temperature,west\n+,,0,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:15.995033574Z,55,value,temperature,west\n+,,0,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.063594313Z,55,value,temperature,west\n+,,0,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.069518557Z,55,value,temperature,west\n+#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string\n+#group,false,false,true,true,false,false,true,true,true\n+#default,_result,,,,,,,,\n,result,table,_start,_stop,_time,_value,_field,_measurement,location\n-,_result,1,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,\"a,b,\n+,,1,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.063594313Z,\"a,b,\n,c\",text,temperature,west\n+,,1,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.069518557Z,\"a,b,\n+,\"\"c\",text,temperature,west\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "test/fixture/query/simpleResponseLines.json", "new_path": "test/fixture/query/simpleResponseLines.json", "diff": "[\n+ \"#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string\",\n+ \"#group,false,false,true,true,false,false,true,true,true\",\n+ \"#default,_result,,,,,,,,\",\n\",result,table,_start,_stop,_time,_value,_field,_measurement,location\",\n- \",_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:15.995033574Z,55,value,temperature,west\",\n- \",_result,0,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,55,value,temperature,west\",\n+ \",,0,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:15.995033574Z,55,value,temperature,west\",\n+ \",,0,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.063594313Z,55,value,temperature,west\",\n+ \",,0,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.069518557Z,55,value,temperature,west\",\n\"\",\n+ \"#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string\",\n+ \"#group,false,false,true,true,false,false,true,true,true\",\n+ \"#default,_result,,,,,,,,\",\n\",result,table,_start,_stop,_time,_value,_field,_measurement,location\",\n- \",_result,1,1970-01-01T00:00:00Z,2019-12-11T13:01:05.472664621Z,1970-01-01T00:26:16.063594313Z,\\\"a,b,\\n,c\\\",text,temperature,west\"\n+ \",,1,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.063594313Z,\\\"a,b,\\n,c\\\",text,temperature,west\",\n+ \",,1,1970-01-01T00:00:00Z,2019-12-12T09:05:37.96237406Z,1970-01-01T00:26:16.069518557Z,\\\"a,b,\\n,\\\"\\\"c\\\",text,temperature,west\"\n]\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: use query samples with annotation lines
305,159
12.12.2019 11:24:50
-3,600
54049d270207ccf7f593d6dea439544f1e20045b
feat: add query example
[ { "change_type": "ADD", "old_path": null, "new_path": "examples/env.ts", "diff": "+export const url = process.env['INFLUXDB_URL'] || 'http://localhost:9999'\n+export const token = process.env['INFLUXDB_TOKEN'] || 'my-token'\n+export const org = 'my-org'\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/query.ts", "diff": "+#!../node_modules/.bin/ts-node\n+import {InfluxDB} from '../src'\n+import {url, token, org} from './env'\n+\n+const queryApi = new InfluxDB({url, token}).getQueryApi(org)\n+\n+queryApi.queryRaw(\n+ 'from(bucket:\"my-bucket\") |> range(start: 0) |> filter(fn: (r) => r._measurement == \"temperature\")',\n+ {\n+ error(error: Error) {\n+ console.error(error)\n+ console.log('\\nFinished ERROR')\n+ },\n+ next(line: string) {\n+ console.log(line)\n+ },\n+ complete() {\n+ console.log('\\nFinished SUCCESS')\n+ },\n+ }\n+)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/setupInfluxDB.ts", "diff": "+#!../node_modules/.bin/ts-node\n+\n+import NodeHttpTransport from '../src/impl/NodeHttpTransport'\n+import {url} from './env'\n+\n+// Post onBoarding request is required for a new database to setup initial user (my-user@my-password),\n+// org (my-org) and bucketSetup (my-bucket) for next examples.\n+//\n+// curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \\\n+// -d '{\n+// \"username\": \"my-user\",\n+// \"password\": \"my-password\",\n+// \"org\": \"my-org\",\n+// \"bucket\": \"my-bucket\",\n+// \"token\": \"my-token\"\n+// }'\n+\n+// TODO use InfluxDB API herein\n+new NodeHttpTransport({\n+ url,\n+}).send(\n+ '/api/v2/setup',\n+ JSON.stringify({\n+ username: 'my-user',\n+ password: 'my-password',\n+ org: 'my-org',\n+ bucket: 'my-bucket',\n+ token: 'my-token',\n+ }),\n+ {method: 'POST', headers: {accept: 'application/json'}},\n+ {\n+ error(error: Error) {\n+ console.error(error)\n+ console.log('\\nFinished ERROR')\n+ },\n+ next(line: any) {\n+ console.log(line)\n+ },\n+ complete() {\n+ console.log('\\nFinished SUCCESS')\n+ },\n+ }\n+)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add query example
305,159
12.12.2019 13:50:24
-3,600
eeaa7682fc5ef8850154527e49b45bf47f2426d8
feat: add simple write example
[ { "change_type": "MODIFY", "old_path": "examples/env.ts", "new_path": "examples/env.ts", "diff": "+/*\n+Exports constants that are used by examples herein.\n+*/\n+\nexport const url = process.env['INFLUXDB_URL'] || 'http://localhost:9999'\nexport const token = process.env['INFLUXDB_TOKEN'] || 'my-token'\n+\nexport const org = 'my-org'\n+export const username = 'my-user'\n+export const password = 'my-password'\n+export const bucket = 'my-bucket'\n" }, { "change_type": "MODIFY", "old_path": "examples/query.ts", "new_path": "examples/query.ts", "diff": "#!../node_modules/.bin/ts-node\n+//////////////////////////////////////////\n+// Shows how to use InfluxDB query API. //\n+//////////////////////////////////////////\n+\nimport {InfluxDB} from '../src'\nimport {url, token, org} from './env'\nconst queryApi = new InfluxDB({url, token}).getQueryApi(org)\n+// performs query and receive line results in annotated csv format\n+// https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/\nqueryApi.queryRaw(\n'from(bucket:\"my-bucket\") |> range(start: 0) |> filter(fn: (r) => r._measurement == \"temperature\")',\n{\n" }, { "change_type": "MODIFY", "old_path": "examples/setupInfluxDB.ts", "new_path": "examples/setupInfluxDB.ts", "diff": "#!../node_modules/.bin/ts-node\n+/*\n+This example setups a new INFLUXDB database with user,organization\n+and bucket that can be then used in examples. All values that used\n+for onboarding are defined in ./env.ts .\n+*/\nimport NodeHttpTransport from '../src/impl/NodeHttpTransport'\n-import {url} from './env'\n+import {url, username, password, org, bucket, token} from './env'\n-// Post onBoarding request is required for a new database to setup initial user (my-user@my-password),\n-// org (my-org) and bucketSetup (my-bucket) for next examples.\n-//\n-// curl -i -X POST http://localhost:9999/api/v2/setup -H 'accept: application/json' \\\n-// -d '{\n-// \"username\": \"my-user\",\n-// \"password\": \"my-password\",\n-// \"org\": \"my-org\",\n-// \"bucket\": \"my-bucket\",\n-// \"token\": \"my-token\"\n-// }'\n-\n-// TODO use InfluxDB API herein\n+// TODO better to use InfluxDB API herein\nnew NodeHttpTransport({\nurl,\n}).send(\n'/api/v2/setup',\nJSON.stringify({\n- username: 'my-user',\n- password: 'my-password',\n- org: 'my-org',\n- bucket: 'my-bucket',\n- token: 'my-token',\n+ username,\n+ password,\n+ org,\n+ bucket,\n+ token,\n}),\n{method: 'POST', headers: {accept: 'application/json'}},\n{\n@@ -33,8 +26,8 @@ new NodeHttpTransport({\nconsole.error(error)\nconsole.log('\\nFinished ERROR')\n},\n- next(line: any) {\n- console.log(line)\n+ next(data: any) {\n+ console.log(Buffer.isBuffer(data) ? data.toString('utf8') : String(data))\n},\ncomplete() {\nconsole.log('\\nFinished SUCCESS')\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/write.ts", "diff": "+#!../node_modules/.bin/ts-node\n+//////////////////////////////////////////\n+// Shows how to use InfluxDB write API. //\n+//////////////////////////////////////////\n+\n+import {InfluxDB, Point} from '../src'\n+import {url, token, org, bucket} from './env'\n+\n+const writeApi = new InfluxDB({url, token}).getWriteApi(org, bucket)\n+// setup default tags for all writes through this API\n+writeApi.useDefaultTags({hostname: require('os').hostname()})\n+// writes a simple record to the database\n+writeApi.writePoint(\n+ new Point('temperature').tag('example', 'write.ts').floatField('value', 28.3)\n+)\n+// flushes pending data and closes writeApi, required before the process terminates\n+writeApi\n+ .close()\n+ .then(() => {\n+ console.log('FINISHED ... now try ./query.ts')\n+ })\n+ .catch((e: Error) => {\n+ console.log('FAILED ... the data might not send to the server')\n+ })\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"lint:ci\": \"yarn run lint --format junit --output-file reports/eslint/eslint.xml\",\n\"lint:fix\": \"eslint --fix 'src/**/*.ts'\"\n},\n- \"homepage\": \"https://github.com/influxdata/influxdb2-client-js\",\n+ \"homepage\": \"https://github.com/bonitoo-io/influxdb-client-js\",\n\"keywords\": [\n\"influxdb\",\n\"influxdata\"\n" }, { "change_type": "MODIFY", "old_path": "src/WriteApi.ts", "new_path": "src/WriteApi.ts", "diff": "@@ -15,14 +15,14 @@ export default interface WriteApi {\nuseDefaultTags(tags: {[key: string]: string}): void\n/**\n- * Write Line Protocol record.\n+ * Write a line of <a href=\"https://bit.ly/2QL99fu\">Line Protocol</a>.\n*\n* @param record line in InfluxDB Line Protocol.\n*/\nwriteRecord(record: string): void\n/**\n- * Write Line Protocol record.\n+ * Write lines of <a href=\"https://bit.ly/2QL99fu\">Line Protocol</a>.\n*\n* @param records lines in InfluxDB Line Protocol\n*/\n@@ -36,7 +36,7 @@ export default interface WriteApi {\nwritePoint(point: Point): void\n/**\n- * Write point.\n+ * Write points.\n*\n* @param records lines in InfluxDB Line Protocol\n*/\n" }, { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -224,8 +224,10 @@ export class NodeHttpTransport implements Transport {\n}\n},\nerror: (error: Error): void => {\n- if (state === 0 && canRetryHttpCall(error)) {\n+ /* istanbul ignore else propagate error at most once */\n+ if (state === 0) {\nstate = 1\n+ if (canRetryHttpCall(error)) {\nconst retries = requestMessage.retries || 0\nif (retries < requestMessage.maxRetries) {\nrequestMessage.retries = retries + 1\n@@ -243,6 +245,7 @@ export class NodeHttpTransport implements Transport {\n}\n/* istanbul ignore else safety check */\nif (callbacks.error) callbacks.error(error)\n+ }\n},\ncomplete: (): void => {\nif (state === 0) {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add simple write example
305,159
12.12.2019 14:49:23
-3,600
1d1cbd5630e6a71f0b073cdcacf7001e97499c39
chore: fix spelling typo in precision
[ { "change_type": "MODIFY", "old_path": "src/InfluxDB.ts", "new_path": "src/InfluxDB.ts", "diff": "import WriteApi from './WriteApi'\n-import {ClientOptions, WritePrecission} from './options'\n+import {ClientOptions, WritePrecision} from './options'\nimport WriteApiImpl from './impl/WriteApiImpl'\nimport {parse} from 'url'\nimport {IllegalArgumentError} from './errors'\n@@ -71,18 +71,18 @@ export default class InfluxDB {\n*\n* @param org Specifies the destination organization for writes. Takes either the ID or Name interchangeably.\n* @param bucket The destination bucket for writes.\n- * @param precission Timestamp precision for line items.\n+ * @param precision Timestamp precision for line items.\n*/\ngetWriteApi(\norg: string,\nbucket: string,\n- precission: WritePrecission = WritePrecission.ms\n+ precision: WritePrecision = WritePrecision.ms\n): WriteApi {\nreturn new WriteApiImpl(\nthis.transport,\norg,\nbucket,\n- precission,\n+ precision,\nthis._options\n)\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "import WriteApi from '../WriteApi'\nimport {\n- WritePrecission,\n+ WritePrecision,\nDEFAULT_WriteOptions,\nClientOptions,\nDEFAULT_ConnectionOptions,\n@@ -66,12 +66,12 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\ntransport: Transport,\norg: string,\nbucket: string,\n- precision: WritePrecission,\n+ precision: WritePrecision,\nclientOptions: ClientOptions\n) {\nconst httpPath = `/api/v2/write?org=${encodeURIComponent(\norg\n- )}&bucket=${encodeURIComponent(bucket)}&precission=${precision}`\n+ )}&bucket=${encodeURIComponent(bucket)}&precision=${precision}`\nconst writeOptions = {\n...DEFAULT_WriteOptions,\n...clientOptions.writeOptions,\n@@ -184,6 +184,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\nwritePoint(point: Point): void {\nconst line = point.toLineProtocol(this)\n+ console.log(line)\nif (line) this.buffer.add(line)\n}\nwritePoints(points: ArrayLike<Point>): void {\n" }, { "change_type": "MODIFY", "old_path": "src/options.ts", "new_path": "src/options.ts", "diff": "@@ -45,7 +45,7 @@ export interface ClientOptions extends ConnectionOptions {\ntransport?: Transport\n}\n-export const enum WritePrecission {\n+export const enum WritePrecision {\n/** nanosecond */\nns = 'ns',\n/* microsecond */\n" }, { "change_type": "MODIFY", "old_path": "src/util/currentTime.ts", "new_path": "src/util/currentTime.ts", "diff": "-import {WritePrecission} from '../options'\n+import {WritePrecision} from '../options'\ndeclare let process: any\nconst zeroPadding = '000000000'\n@@ -38,10 +38,10 @@ function seconds(): string {\n}\nexport const currentTimes = Object.freeze({\n- [String(WritePrecission.s)]: seconds,\n- [String(WritePrecission.ms)]: millis,\n- [String(WritePrecission.us)]: micros,\n- [String(WritePrecission.ns)]: nanos,\n+ [String(WritePrecision.s)]: seconds,\n+ [String(WritePrecision.ms)]: millis,\n+ [String(WritePrecision.us)]: micros,\n+ [String(WritePrecision.ns)]: nanos,\nseconds,\nmillis,\nmicros,\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -3,7 +3,7 @@ import nock from 'nock' // WARN: nock must be imported before NodeHttpTransport,\nimport NodeHttpTransport from '../../../src/impl/NodeHttpTransport'\nimport {\nClientOptions,\n- WritePrecission,\n+ WritePrecision,\nDEFAULT_WriteOptions,\nWriteOptions,\nPoint,\n@@ -20,9 +20,9 @@ const clientOptions: ClientOptions = {\nconst transport = new NodeHttpTransport(clientOptions)\nconst ORG = 'org'\nconst BUCKET = 'bucket'\n-const PRECISSION = WritePrecission.s\n+const PRECISION = WritePrecision.s\n-const WRITE_PATH_NS = `/api/v2/write?org=${ORG}&bucket=${BUCKET}&precission=ns`\n+const WRITE_PATH_NS = `/api/v2/write?org=${ORG}&bucket=${BUCKET}&precision=ns`\ndescribe('WriteApiImpl', () => {\nbeforeEach(() => {\n@@ -40,7 +40,7 @@ describe('WriteApiImpl', () => {\ntransport,\nORG,\nBUCKET,\n- PRECISSION,\n+ PRECISION,\nclientOptions\n)\n// logs = collectLogging.decorate()\n@@ -82,7 +82,7 @@ describe('WriteApiImpl', () => {\nlet subject: WriteApiImpl\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISSION, {\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n...clientOptions,\nwriteOptions,\n})\n@@ -127,7 +127,7 @@ describe('WriteApiImpl', () => {\nlet subject: WriteApiImpl\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISSION, {\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n...clientOptions,\nwriteOptions,\n})\n@@ -158,7 +158,7 @@ describe('WriteApiImpl', () => {\nlet subject: WriteApi\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, WritePrecission.ns, {\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, WritePrecision.ns, {\n...clientOptions,\nwriteOptions,\n}).useDefaultTags({xtra: '1'})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/influxdb.test.ts", "new_path": "test/unit/influxdb.test.ts", "diff": "import {expect} from 'chai'\n-import {InfluxDB, ClientOptions, WritePrecission} from '../../src'\n+import {InfluxDB, ClientOptions, WritePrecision} from '../../src'\ndescribe('influxdb', () => {\ndescribe('constructor', () => {\n@@ -66,7 +66,7 @@ describe('influxdb', () => {\nconst influxDb = new InfluxDB('http://localhost:9999?token=a')\nit('serves queryApi writeApi without a pending schedule', () => {\nexpect(influxDb.getWriteApi('org', 'bucket')).to.be.ok\n- expect(influxDb.getWriteApi('org', 'bucket', WritePrecission.s)).to.be.ok\n+ expect(influxDb.getWriteApi('org', 'bucket', WritePrecision.s)).to.be.ok\n})\nit('serves queryApi', () => {\nexpect(influxDb.getQueryApi('my-org') as any)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: fix spelling typo in precision
305,159
12.12.2019 15:11:55
-3,600
e610b5aed4cd7357526be0de83763a72ddf8a025
feat: use ns precision ootb, always generate unique ns timestamp
[ { "change_type": "MODIFY", "old_path": "src/InfluxDB.ts", "new_path": "src/InfluxDB.ts", "diff": "@@ -76,7 +76,7 @@ export default class InfluxDB {\ngetWriteApi(\norg: string,\nbucket: string,\n- precision: WritePrecision = WritePrecision.ms\n+ precision: WritePrecision = WritePrecision.ns\n): WriteApi {\nreturn new WriteApiImpl(\nthis.transport,\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -11,7 +11,7 @@ import Logger from './Logger'\nimport {getRetryDelay, HttpError} from '../errors'\nimport Point from '../Point'\nimport {escape} from '../util/escape'\n-import {currentTimes} from '../util/currentTime'\n+import {currentTime} from '../util/currentTime'\nclass WriteBuffer {\nlength = 0\n@@ -76,7 +76,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n...DEFAULT_WriteOptions,\n...clientOptions.writeOptions,\n}\n- this.currentTime = currentTimes[precision]\n+ this.currentTime = currentTime[precision]\nconst sendOptions: Partial<SendOptions> = {\nmethod: 'POST',\nmaxRetries: 0, // we control manual retry attempts\n" }, { "change_type": "MODIFY", "old_path": "src/util/currentTime.ts", "new_path": "src/util/currentTime.ts", "diff": "@@ -9,13 +9,23 @@ export function useProcessHrtime(use: boolean): boolean {\n}\nuseProcessHrtime(true) // preffer node\n+let lastMillis = Date.now()\n+let stepsInMillis = 0\nfunction nanos(): string {\nif (useHrTime) {\nconst hrTime = process.hrtime() as [number, number]\nconst nanos = String(hrTime[1] % 1000000)\nreturn String(Date.now()) + zeroPadding.substr(0, 6 - nanos.length) + nanos\n} else {\n- return String(Date.now()) + zeroPadding.substr(0, 6)\n+ const millis = Date.now()\n+ if (millis !== lastMillis) {\n+ lastMillis = millis\n+ stepsInMillis = 0\n+ } else {\n+ stepsInMillis++\n+ }\n+ const nanos = String(stepsInMillis)\n+ return String(Date.now()) + zeroPadding.substr(0, 6 - nanos.length) + nanos\n}\n}\n@@ -37,7 +47,7 @@ function seconds(): string {\nreturn String(Math.floor(Date.now() / 1000))\n}\n-export const currentTimes = Object.freeze({\n+export const currentTime = Object.freeze({\n[String(WritePrecision.s)]: seconds,\n[String(WritePrecision.ms)]: millis,\n[String(WritePrecision.us)]: micros,\n" }, { "change_type": "MODIFY", "old_path": "test/unit/util/currentTime.test.ts", "new_path": "test/unit/util/currentTime.test.ts", "diff": "-import {currentTimes, useProcessHrtime} from '../../../src'\n+import {currentTime, useProcessHrtime} from '../../../src'\nimport {expect} from 'chai'\ndescribe('currentTime', () => {\n@@ -19,7 +19,7 @@ describe('currentTime', () => {\nexpect(useProcessApi).to.be.equal(useHrtime)\n})\nit('calculates time in seconds', () => {\n- const val = currentTimes['s']()\n+ const val = currentTime['s']()\nconst ms = Date.now()\nexpect(val).to.have.length(\nString(Math.floor(Date.now() / 1000)).length\n@@ -27,25 +27,35 @@ describe('currentTime', () => {\nexpect(Math.abs(parseInt(val) - ms / 1000)).to.be.lessThan(5)\n})\nit('calculates time in milliseconds', () => {\n- const val = currentTimes['ms']()\n+ const val = currentTime['ms']()\nconst ms = Date.now()\nexpect(val).to.have.length(String(Date.now()).length)\nexpect(Math.abs(parseInt(val) - ms)).to.be.lessThan(5000)\n})\nit('calculates time in microseconds', () => {\n- const val = currentTimes['us']()\n+ const val = currentTime['us']()\nconst ms = Date.now()\nexpect(val).to.have.length(String(Date.now()).length + 3)\nexpect(Math.abs(parseInt(val) - ms * 1000)).to.be.lessThan(5000000)\n})\nit('calculates time in nanoseconds', () => {\n- const val = currentTimes['ns']()\n+ const val = currentTime['ns']()\nconst ms = Date.now()\nexpect(val).to.have.length(String(Date.now()).length + 6)\nexpect(Math.abs(parseInt(val) - ms * 1000000)).to.be.lessThan(\n5000000000\n)\n})\n+ it('returns different nanoseconds even when pushed quickly', () => {\n+ const size = 100\n+ const data = new Array(size)\n+ for (let i = 0; i < size; i++) {\n+ data[i] = currentTime.nanos()\n+ }\n+ for (let i = 1; i < size; i++) {\n+ expect(BigInt(data[i - 1]) < BigInt(data[i])).to.be.true\n+ }\n+ })\n}\n)\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: use ns precision ootb, always generate unique ns timestamp
305,159
13.12.2019 11:02:24
-3,600
5d42cae692ba03c3d48b3f03c849b3e4a971d909
fix: enhance current time tests and impl
[ { "change_type": "MODIFY", "old_path": "src/util/currentTime.ts", "new_path": "src/util/currentTime.ts", "diff": "@@ -9,13 +9,27 @@ export function useProcessHrtime(use: boolean): boolean {\n}\nuseProcessHrtime(true) // preffer node\n+let startHrMillis: number | undefined = undefined\n+let startHrTime: [number, number] | undefined = undefined\nlet lastMillis = Date.now()\nlet stepsInMillis = 0\nfunction nanos(): string {\nif (useHrTime) {\nconst hrTime = process.hrtime() as [number, number]\n- const nanos = String(hrTime[1] % 1000000)\n- return String(Date.now()) + zeroPadding.substr(0, 6 - nanos.length) + nanos\n+ let millis = Date.now()\n+ if (!startHrTime) {\n+ startHrTime = hrTime\n+ startHrMillis = millis\n+ } else {\n+ hrTime[0] = hrTime[0] - startHrTime[0]\n+ hrTime[1] = hrTime[1] - startHrTime[1]\n+ millis =\n+ (startHrMillis as number) +\n+ hrTime[0] * 1000 +\n+ Math.floor(hrTime[1] / 1000_000)\n+ }\n+ const nanos = String(hrTime[1] % 1000_000)\n+ return String(millis) + zeroPadding.substr(0, 6 - nanos.length) + nanos\n} else {\nconst millis = Date.now()\nif (millis !== lastMillis) {\n@@ -25,7 +39,7 @@ function nanos(): string {\nstepsInMillis++\n}\nconst nanos = String(stepsInMillis)\n- return String(Date.now()) + zeroPadding.substr(0, 6 - nanos.length) + nanos\n+ return String(millis) + zeroPadding.substr(0, 6 - nanos.length) + nanos\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/util/currentTime.test.ts", "new_path": "test/unit/util/currentTime.test.ts", "diff": "@@ -46,14 +46,28 @@ describe('currentTime', () => {\n5000000000\n)\n})\n- it('returns different nanoseconds even when pushed quickly', () => {\n+ it('returns different nanoseconds even when pushed quickly', async () => {\nconst size = 100\nconst data = new Array(size)\n- for (let i = 0; i < size; i++) {\n+ for (let i = 0; i < size / 2; i++) {\ndata[i] = currentTime.nanos()\n}\n+ await new Promise<void>((resolve, _reject) =>\n+ setTimeout(() => resolve(), 1)\n+ )\n+ for (let i = size / 50; i < size; i++) {\n+ data[i] = currentTime.nanos()\n+ }\n+\nfor (let i = 1; i < size; i++) {\n- expect(BigInt(data[i - 1]) < BigInt(data[i])).to.be.true\n+ console.log(`useProcessApi=${useProcessApi} ${data[i - 1]}`)\n+ if (BigInt(data[i - 1]) >= BigInt(data[i])) {\n+ expect.fail(\n+ `(${i}) ${data[i - 1]} < ${\n+ data[i]\n+ } is not true with useProcessApi=${useProcessApi}`\n+ )\n+ }\n}\n})\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: enhance current time tests and impl
305,159
13.12.2019 18:59:30
-3,600
bd7efb2a1f0cce06c5b45b4d13236eb5649043e8
feat(query api): create objects from records using table metadata
[ { "change_type": "MODIFY", "old_path": "src/impl/linesToTables.ts", "new_path": "src/impl/linesToTables.ts", "diff": "@@ -2,7 +2,7 @@ import {CommunicationObserver} from '../transport'\nimport Cancellable from '../util/Cancellable'\nimport FluxResultObserver from '../query/FluxResultObserver'\nimport LineSplitter from '../util/LineSplitter'\n-import {FluxTableColumn, ColumnType} from '../query/FluxTableColumn'\n+import FluxTableColumn, {ColumnType} from '../query/FluxTableColumn'\nimport FluxTableMetaData from '../query/FluxTableMetaData'\nexport function toLineObserver(\n@@ -12,6 +12,7 @@ export function toLineObserver(\nlet columns: FluxTableColumn[] | undefined\nlet expectMeta = true\nlet firstColumnIndex = 0\n+ let lastMeta: FluxTableMetaData\nreturn {\nerror(error: Error): void {\nconsumer.error(error)\n@@ -42,7 +43,7 @@ export function toLineObserver(\nfor (let i = firstColumnIndex; i < size; i++) {\ncolumns[i - firstColumnIndex].label = values[i]\n}\n- consumer.tableMetaData(new FluxTableMetaData(columns))\n+ lastMeta = new FluxTableMetaData(columns)\nexpectMeta = false\n} else if (values[0] === '#datatype') {\nfor (let i = 1; i < size; i++) {\n@@ -58,7 +59,7 @@ export function toLineObserver(\n}\n}\n} else {\n- consumer.nextRow(values.slice(firstColumnIndex, size))\n+ consumer.nextRow(lastMeta, values.slice(firstColumnIndex, size))\n}\n}\n},\n" }, { "change_type": "MODIFY", "old_path": "src/query/FluxResultObserver.ts", "new_path": "src/query/FluxResultObserver.ts", "diff": "@@ -5,14 +5,10 @@ import FluxTableMetaData from './FluxTableMetaData'\n* Observes the results of the flux query.\n*/\nexport default interface FluxResultObserver<T> {\n- /**\n- * Informs about table metadata of next rows.\n- */\n- tableMetaData(tableMeta: FluxTableMetaData): void\n/**\n* Inform about a next record in a table.\n*/\n- nextRow(row: T): void\n+ nextRow(tableMeta: FluxTableMetaData, row: T): void\n/**\n* Signalizes processing error.\n*/\n" }, { "change_type": "MODIFY", "old_path": "src/query/FluxTableColumn.ts", "new_path": "src/query/FluxTableColumn.ts", "diff": "@@ -14,7 +14,7 @@ export type ColumnType =\n/**\n* Represents column metadata of a flux <a href=\"http://bit.ly/flux-spec#table\">table</a>.\n*/\n-export class FluxTableColumn {\n+export default class FluxTableColumn {\n/**\n* Label (e.g., \"_start\", \"_stop\", \"_time\").\n*/\n@@ -34,4 +34,17 @@ export class FluxTableColumn {\n* Default value to be used for rows whose string value is the empty string.\n*/\ndefaultValue: string\n+\n+ /**\n+ * Creates a flux table column from an object supplied.\n+ * @param object\n+ */\n+ static from(object: any): FluxTableColumn {\n+ const retVal = new FluxTableColumn()\n+ retVal.label = object.label\n+ retVal.dataType = object.dataType as ColumnType\n+ retVal.group = Boolean(object.group)\n+ retVal.defaultValue = object.defaultValue\n+ return retVal\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "src/query/FluxTableMetaData.ts", "new_path": "src/query/FluxTableMetaData.ts", "diff": "-import {FluxTableColumn} from './FluxTableColumn'\n+import FluxTableColumn from './FluxTableColumn'\n+import {IllegalArgumentError} from '../errors'\n/**\n* Represents metadata of a flux <a href=\"http://bit.ly/flux-spec#table\">table</a>.\n*/\n-export default class FluxTableMetaData {\n- columns: FluxTableColumn[]\n+export class FluxTableMetaData {\n+ /**\n+ * Table columns.\n+ */\n+ columns: Array<FluxTableColumn>\nconstructor(columns: FluxTableColumn[]) {\nthis.columns = columns\n}\n+ /**\n+ * Gets columns by name\n+ * @param label table column or [[invalidColumn]]\n+ */\n+ column(label: string): FluxTableColumn {\n+ for (let i = 0; i < this.columns.length; i++) {\n+ const col = this.columns[i]\n+ if (col.label === label) return col\n+ }\n+ throw new IllegalArgumentError(`Column ${label} not found!`)\n+ }\n+ /**\n+ * Creates an object accordin to columns and supplied record.\n+ * @param values values for each column\n+ */\n+ toObject(values: string[]): {[key: string]: string} {\n+ const acc: any = {}\n+ for (let i = 0; i < this.columns.length && i < values.length; i++) {\n+ let val = values[i]\n+ const column = this.columns[i]\n+ if (val === '' && column.defaultValue) {\n+ val = column.defaultValue\n+ }\n+ acc[column.label] = val\n}\n+ return acc\n+ }\n+}\n+\n+export default FluxTableMetaData\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/query/FluxTableMetaData.test.ts", "diff": "+import FluxTableColumn from '../../../src/query/FluxTableColumn'\n+import {FluxTableMetaData} from '../../../src/query/FluxTableMetaData'\n+import {expect} from 'chai'\n+\n+describe('FluxTableMetaData', () => {\n+ it('returns columns by name or id', () => {\n+ const columns: FluxTableColumn[] = [\n+ FluxTableColumn.from({\n+ label: 'a',\n+ defaultValue: 'def',\n+ type: 'long',\n+ group: false,\n+ }),\n+ FluxTableColumn.from({\n+ label: 'b',\n+ }),\n+ ]\n+ const subject = new FluxTableMetaData(columns)\n+ expect(subject.column('a')).to.equals(columns[0])\n+ expect(subject.column('b')).to.equals(columns[1])\n+ expect(subject.columns[0]).to.equals(columns[0])\n+ expect(subject.columns[1]).to.equals(columns[1])\n+ expect(() => subject.column('c')).to.throw()\n+ })\n+ it('creates objects', () => {\n+ const columns: FluxTableColumn[] = [\n+ FluxTableColumn.from({\n+ label: 'a',\n+ defaultValue: 'def',\n+ type: 'long',\n+ group: false,\n+ }),\n+ FluxTableColumn.from({\n+ label: 'b',\n+ }),\n+ ]\n+ const subject = new FluxTableMetaData(columns)\n+ expect(subject.toObject(['', ''])).to.deep.equal({a: 'def', b: ''})\n+ expect(subject.toObject(['x', 'y'])).to.deep.equal({a: 'x', b: 'y'})\n+ expect(subject.toObject(['x', 'y', 'z'])).to.deep.equal({a: 'x', b: 'y'})\n+ expect(subject.toObject(['x'])).to.deep.equal({a: 'x'})\n+ })\n+})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/util/CollectTablesObserver.ts", "new_path": "test/unit/util/CollectTablesObserver.ts", "diff": "@@ -8,15 +8,16 @@ export class CollectTablesObserver implements FluxResultObserver<string[]> {\nfailed = 0\ncancellableSet = false\nindex = 0\n+ lastMeta: FluxTableMetaData\nresolve?: (value?: void) => void\nreject?: (reason?: any) => void\n- tableMetaData(meta: FluxTableMetaData): void {\n+ nextRow(meta: FluxTableMetaData, row: string[]): void {\n+ if (this.lastMeta !== meta) {\nthis.tables.push({index: this.index++, meta})\n+ this.lastMeta = meta\n}\n-\n- nextRow(row: string[]): void {\nthis.rows.push({index: this.index++, row})\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(query api): create objects from records using table metadata
305,159
13.12.2019 19:04:38
-3,600
b498f0c0089b4b26dc8af72845a91632549e2c35
feat(query api): add queryRows
[ { "change_type": "MODIFY", "old_path": "src/QueryApi.ts", "new_path": "src/QueryApi.ts", "diff": "@@ -50,5 +50,5 @@ export default interface QueryApi {\n* @param record single line in the query result\n* @param consumer data/error consumer\n*/\n- queryTables(query: string, consumer: FluxResultObserver<string[]>): void\n+ queryRows(query: string, consumer: FluxResultObserver<string[]>): void\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/QueryApiImpl.ts", "new_path": "src/impl/QueryApiImpl.ts", "diff": "@@ -41,7 +41,7 @@ export class QueryApiImpl implements QueryApi {\n)\n}\n- queryTables(query: string, consumer: FluxResultObserver<string[]>): void {\n+ queryRows(query: string, consumer: FluxResultObserver<string[]>): void {\nthis.queryLines(query, toLineObserver(consumer))\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/QueryApi.test.ts", "new_path": "test/unit/QueryApi.test.ts", "diff": "@@ -57,7 +57,7 @@ describe('QueryApi', () => {\n.persist()\nconst target = new CollectTablesObserver()\nawait new Promise((resolve, reject) =>\n- subject.queryTables(\n+ subject.queryRows(\n'from(bucket:\"my-bucket\") |> range(start: 0)',\ntarget.attach(resolve, reject)\n)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(query api): add queryRows
305,159
13.12.2019 19:44:51
-3,600
c683f224a172ef1534ee1d6cf173ba911d0eb4ac
feat(query api): add query example
[ { "change_type": "MODIFY", "old_path": "examples/query.ts", "new_path": "examples/query.ts", "diff": "import {InfluxDB} from '../src'\nimport {url, token, org} from './env'\n+import FluxTableMetaData from '../src/query/FluxTableMetaData'\nconst queryApi = new InfluxDB({url, token}).getQueryApi(org)\n+const fluxQuery =\n+ 'from(bucket:\"my-bucket\") |> range(start: 0) |> filter(fn: (r) => r._measurement == \"temperature\")'\n-// performs query and receive line results in annotated csv format\n+console.log('*** QUERY ROWS ***')\n+// performs query and receive line table metadata and rows\n// https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/\n-queryApi.queryLines(\n- 'from(bucket:\"my-bucket\") |> range(start: 0) |> filter(fn: (r) => r._measurement == \"temperature\")',\n- {\n+queryApi.queryRows(fluxQuery, {\n+ next(row: string[], tableMeta: FluxTableMetaData) {\n+ const o = tableMeta.toObject(row)\n+ // console.log(JSON.stringify(o, null, 2))\n+ console.log(\n+ `${o._time} ${o._measurement} at ${o.hostname}: ${o._field}=${o._value}`\n+ )\n+ },\nerror(error: Error) {\nconsole.error(error)\nconsole.log('\\nFinished ERROR')\n},\n- next(line: string) {\n- console.log(line)\n- },\ncomplete() {\nconsole.log('\\nFinished SUCCESS')\n},\n- }\n-)\n+})\n+\n+// performs query and receive line results in annotated csv format\n+// https://v2.docs.influxdata.com/v2.0/reference/syntax/annotated-csv/\n+// queryApi.queryLines(\n+// fluxQuery,\n+// {\n+// error(error: Error) {\n+// console.error(error)\n+// console.log('\\nFinished ERROR')\n+// },\n+// next(line: string) {\n+// console.log(line)\n+// },\n+// complete() {\n+// console.log('\\nFinished SUCCESS')\n+// },\n+// }\n+// )\n" }, { "change_type": "MODIFY", "old_path": "examples/write.ts", "new_path": "examples/write.ts", "diff": "@@ -9,15 +9,25 @@ import {url, token, org, bucket} from './env'\nconst writeApi = new InfluxDB({url, token}).getWriteApi(org, bucket)\n// setup default tags for all writes through this API\nwriteApi.useDefaultTags({hostname: require('os').hostname()})\n+\n+console.log('*** WRITE POINTS ***')\n// writes a simple record to the database\nwriteApi.writePoint(\n- new Point('temperature').tag('example', 'write.ts').floatField('value', 28.3)\n+ new Point('temperature')\n+ .tag('example', 'write.ts')\n+ .floatField('value', 20 + Math.round(100 * Math.random()) / 10)\n+)\n+writeApi.writePoint(\n+ new Point('temperature')\n+ .tag('example', 'write.ts')\n+ .floatField('value', 20 + Math.round(100 * Math.random()) / 10)\n)\n-// flushes pending data and closes writeApi, required before the process terminates\n+\n+// flush pending writes and close writeApi\nwriteApi\n.close()\n.then(() => {\n- console.log('FINISHED ... now try ./query.ts')\n+ console.log('FINISHED ... try ./query.ts')\n})\n.catch((e: Error) => {\nconsole.log('FAILED ... the data might not send to the server')\n" }, { "change_type": "MODIFY", "old_path": "src/impl/linesToTables.ts", "new_path": "src/impl/linesToTables.ts", "diff": "@@ -59,7 +59,7 @@ export function toLineObserver(\n}\n}\n} else {\n- consumer.nextRow(lastMeta, values.slice(firstColumnIndex, size))\n+ consumer.next(values.slice(firstColumnIndex, size), lastMeta)\n}\n}\n},\n" }, { "change_type": "MODIFY", "old_path": "src/query/FluxResultObserver.ts", "new_path": "src/query/FluxResultObserver.ts", "diff": "@@ -8,7 +8,7 @@ export default interface FluxResultObserver<T> {\n/**\n* Inform about a next record in a table.\n*/\n- nextRow(tableMeta: FluxTableMetaData, row: T): void\n+ next(row: T, tableMeta: FluxTableMetaData): void\n/**\n* Signalizes processing error.\n*/\n" }, { "change_type": "MODIFY", "old_path": "test/unit/util/CollectTablesObserver.ts", "new_path": "test/unit/util/CollectTablesObserver.ts", "diff": "@@ -13,7 +13,7 @@ export class CollectTablesObserver implements FluxResultObserver<string[]> {\nresolve?: (value?: void) => void\nreject?: (reason?: any) => void\n- nextRow(meta: FluxTableMetaData, row: string[]): void {\n+ next(row: string[], meta: FluxTableMetaData): void {\nif (this.lastMeta !== meta) {\nthis.tables.push({index: this.index++, meta})\nthis.lastMeta = meta\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(query api): add query example
305,159
16.12.2019 09:24:36
-3,600
d162dcde9cdcdcb52765a6b2cabf7266d36eb410
feat: expose query APIs from module
[ { "change_type": "MODIFY", "old_path": "examples/query.ts", "new_path": "examples/query.ts", "diff": "import {InfluxDB} from '../src'\nimport {url, token, org} from './env'\n-import FluxTableMetaData from '../src/query/FluxTableMetaData'\n+import {FluxTableMetaData} from '../src/query'\nconst queryApi = new InfluxDB({url, token}).getQueryApi(org)\nconst fluxQuery =\n" }, { "change_type": "MODIFY", "old_path": "src/index.ts", "new_path": "src/index.ts", "diff": "@@ -2,6 +2,7 @@ export * from './options'\nexport * from './errors'\nexport * from './util/escape'\nexport * from './util/currentTime'\n+export * from './query'\nexport {default as Point} from './Point'\nexport {default as QueryApi} from './QueryApi'\nexport {default as WriteApi} from './WriteApi'\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/query/index.ts", "diff": "+export {default as FluxTableMetaData} from './FluxTableMetaData'\n+export {default as FluxResultObserver} from './FluxResultObserver'\n+export {default as FluxTableColumn, ColumnType} from './FluxTableColumn'\n" }, { "change_type": "MODIFY", "old_path": "test/unit/query/FluxTableMetaData.test.ts", "new_path": "test/unit/query/FluxTableMetaData.test.ts", "diff": "-import FluxTableColumn from '../../../src/query/FluxTableColumn'\n-import FluxTableMetaData from '../../../src/query/FluxTableMetaData'\n+import {FluxTableColumn, FluxTableMetaData} from '../../../src'\nimport {expect} from 'chai'\ndescribe('FluxTableMetaData', () => {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: expose query APIs from module
305,159
16.12.2019 09:24:48
-3,600
769c2d087315e030e253df3faa423c87834f622f
feat: document examples
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -15,15 +15,17 @@ This library is a work in progress and should not be considered production ready\n## ToDos\n- this documentation\n+- add limited buffer for write retries / RX.js\n- all APIs (generated)\n-- use node-fetch API\n-- write buffer / RX.js\n-- monorepo\n+- implement transport for both node and browser, fetch API?\n+- monorepo with yarn, separate examples/experiments\n- browser client howto\n## Usage\n-ToDo\n+- [Examples](./tree/master/examples)\n+ - [Write to InfluxDB](./blob/master/examples/write.ts)\n+ - [Query InfluxDB](./blob/master/examples/examples/query.ts)\n## Build Requirements\n" }, { "change_type": "ADD", "old_path": null, "new_path": "examples/README.md", "diff": "+# InfluxDB Client Examples\n+\n+- Prerequisites\n+ - [https://yarnpkg.com/lang/en/docs/install/](yarn) installed\n+ - Run `yarn install`\n+ - Change variables in [./env.ts](env.ts) to configure connection to your InfluxDB instance. The default settings points to a dockerized influxDB 2 installation as described in [https://v2.docs.influxdata.com/v2.0/get-started/ ](get started)\n+- Examples are executable on unixes, or simple run `yarn ts-node example/EXAMPLE.ts`)\n+ - [./setupInfluxDB.ts](setupInfluxDB.ts) performs onboarding of a new influxDB database (such as those running from docker), it creates a new organization, bucket and user that is then used in examples\n+ - [./write.ts](write.ts) writes data points to InfluxDB\n+ - [./query.ts](query.ts) query InfluxDB (with flux)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: document examples
305,159
16.12.2019 09:32:41
-3,600
875151a68bec370fbe2b69805105634ede3ca7c7
chore: update examples readme
[ { "change_type": "MODIFY", "old_path": "examples/README.md", "new_path": "examples/README.md", "diff": "# InfluxDB Client Examples\n- Prerequisites\n- - [https://yarnpkg.com/lang/en/docs/install/](yarn) installed\n+ - [yarn](https://yarnpkg.com/lang/en/docs/install/) installed\n- Run `yarn install`\n- - Change variables in [./env.ts](env.ts) to configure connection to your InfluxDB instance. The default settings points to a dockerized influxDB 2 installation as described in [https://v2.docs.influxdata.com/v2.0/get-started/ ](get started)\n-- Examples are executable on unixes, or simple run `yarn ts-node example/EXAMPLE.ts`)\n- - [./setupInfluxDB.ts](setupInfluxDB.ts) performs onboarding of a new influxDB database (such as those running from docker), it creates a new organization, bucket and user that is then used in examples\n- - [./write.ts](write.ts) writes data points to InfluxDB\n- - [./query.ts](query.ts) query InfluxDB (with flux)\n+ - Change variables in [./env.ts](env.ts) to configure connection to your InfluxDB instance. The default settings point to a dockerized influxDB 2 installation as described in [https://v2.docs.influxdata.com/v2.0/get-started/ ](get started)\n+- Examples are executable. If it does not work for you, run `yarn ts-node example/EXAMPLE.ts`.\n+ - [setupInfluxDB.ts](./setupInfluxDB.ts)\n+ Performs onboarding of a new influxDB database (such as a new docker pod). It creates a new organization, bucket and user that is then used in examples.\n+ - [write.ts](./write.ts)\n+ Writes data points to InfluxDB.\n+ - [query.ts](./query.ts)\n+ Query InfluxDB (with flux).\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: update examples readme
305,159
16.12.2019 10:50:39
-3,600
47e6dc93bc3777e81012d8f116ffa5ee56adcce1
fix: avoid running npm to workaround nyc coverage not being able to run yarn
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"build:doc\": \"yarn run clean && typedoc --out ./doc ./src\",\n\"clean\": \"rimraf dist build coverage .nyc_output doc *.lcov reports\",\n\"codecov\": \"nyc report --reporter=text-lcov > coverage/coverage.lcov && codecov\",\n- \"coverage\": \"nyc npm run test:unit\",\n+ \"coverage\": \"nyc mocha --require ts-node/register 'test/unit/**/*.test.ts' --exit\",\n\"test\": \"yarn run lint && yarn run typecheck && yarn run test:unit\",\n\"test:unit\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --exit\",\n\"test:unit:ci\": \"yarn run test:unit --exit --reporter mocha-junit-reporter --reporter-options mochaFile=reports/mocha/test-results.xml\",\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: avoid running npm to workaround nyc coverage not being able to run yarn
305,159
16.12.2019 11:51:53
-3,600
8d0c90aef23b5051fec732fa4e258ae050fd895f
chore: repair links, add docs
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -24,9 +24,9 @@ This library is a work in progress and should not be considered production ready\n## Usage\n-- [Examples](./tree/master/examples)\n- - [Write to InfluxDB](./blob/master/examples/write.ts)\n- - [Query InfluxDB](./blob/master/examples/examples/query.ts)\n+- [Examples](./examples)\n+ - [Write to InfluxDB](./examples/write.ts)\n+ - [Query InfluxDB](./examples/query.ts)\n## Build Requirements\n" }, { "change_type": "MODIFY", "old_path": "examples/README.md", "new_path": "examples/README.md", "diff": "- Prerequisites\n- [yarn](https://yarnpkg.com/lang/en/docs/install/) installed\n- Run `yarn install`\n- - Change variables in [./env.ts](env.ts) to configure connection to your InfluxDB instance. The default settings point to a dockerized influxDB 2 installation as described in [https://v2.docs.influxdata.com/v2.0/get-started/ ](get started)\n+ - Change variables in [./env.ts](env.ts) to configure connection to your InfluxDB instance. The file can be used as-is against a [docker influxDB v2.0 installation](https://v2.docs.influxdata.com/v2.0/get-started/)\n- Examples are executable. If it does not work for you, run `yarn ts-node example/EXAMPLE.ts`.\n- [setupInfluxDB.ts](./setupInfluxDB.ts)\nPerforms onboarding of a new influxDB database (such as a new docker pod). It creates a new organization, bucket and user that is then used in examples.\n" }, { "change_type": "MODIFY", "old_path": "examples/env.ts", "new_path": "examples/env.ts", "diff": "Exports constants that are used by examples herein.\n*/\n+/** InfluxDB v2 URL */\nexport const url = process.env['INFLUXDB_URL'] || 'http://localhost:9999'\n+/** InfluxDB authorization token */\nexport const token = process.env['INFLUXDB_TOKEN'] || 'my-token'\n+/** example organization within InfluxDB URL */\nexport const org = 'my-org'\n+/**InfluxDB user */\nexport const username = 'my-user'\n+/**InfluxDB password */\nexport const password = 'my-password'\n+/**InfluxDB bucket used in examples */\nexport const bucket = 'my-bucket'\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: repair links, add docs
305,159
16.12.2019 11:56:46
-3,600
4ffb2d5b94d3bfa85b15c920a40683d0171c7783
chore: bump version to 0.1.0
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "{\n\"name\": \"influxdb2-client\",\n- \"version\": \"0.0.1\",\n+ \"version\": \"0.1.0\",\n\"description\": \"InfluxDB 2.0 client\",\n\"main\": \"dist/index.js\",\n\"module\": \"dist/index.mjs\",\n\"sinon\": \"^7.5.0\",\n\"ts-node\": \"^8.5.4\",\n\"typedoc\": \"^0.15.3\",\n- \"typescript\": \"^3.7.2\"\n+ \"typescript\": \"^3.7.2\",\n+ \"version-bump-prompt\": \"^5.0.6\"\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "lodash \"^4.17.13\"\nto-fast-properties \"^2.0.0\"\n+\"@nodelib/[email protected]\":\n+ version \"2.1.3\"\n+ resolved \"https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b\"\n+ integrity sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw==\n+ dependencies:\n+ \"@nodelib/fs.stat\" \"2.0.3\"\n+ run-parallel \"^1.1.9\"\n+\n+\"@nodelib/[email protected]\", \"@nodelib/fs.stat@^2.0.2\":\n+ version \"2.0.3\"\n+ resolved \"https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz#34dc5f4cabbc720f4e60f75a747e7ecd6c175bd3\"\n+ integrity sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA==\n+\n+\"@nodelib/fs.walk@^1.2.3\":\n+ version \"1.2.4\"\n+ resolved \"https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz#011b9202a70a6366e436ca5c065844528ab04976\"\n+ integrity sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ==\n+ dependencies:\n+ \"@nodelib/fs.scandir\" \"2.1.3\"\n+ fastq \"^1.6.0\"\n+\n\"@sinonjs/commons@^1\", \"@sinonjs/commons@^1.3.0\", \"@sinonjs/commons@^1.4.0\":\nversion \"1.6.0\"\nresolved \"https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.6.0.tgz#ec7670432ae9c8eb710400d112c201a362d83393\"\nversion \"0.0.39\"\nresolved \"https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f\"\n+\"@types/events@*\":\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7\"\n+ integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==\n+\n+\"@types/glob@^7.1.1\":\n+ version \"7.1.1\"\n+ resolved \"https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575\"\n+ integrity sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==\n+ dependencies:\n+ \"@types/events\" \"*\"\n+ \"@types/minimatch\" \"*\"\n+ \"@types/node\" \"*\"\n+\n\"@types/json-schema@^7.0.3\":\nversion \"7.0.3\"\nresolved \"https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636\"\n-\"@types/[email protected]\":\n+\"@types/minimatch@*\", \"@types/[email protected]\":\nversion \"3.0.3\"\nresolved \"https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d\"\n@@ -266,10 +301,20 @@ argv@^0.0.2:\nversion \"0.0.2\"\nresolved \"https://registry.yarnpkg.com/argv/-/argv-0.0.2.tgz#ecbd16f8949b157183711b1bda334f37840185ab\"\n+array-back@^3.0.1:\n+ version \"3.1.0\"\n+ resolved \"https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0\"\n+ integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==\n+\narray-from@^2.1.1:\nversion \"2.1.1\"\nresolved \"https://registry.yarnpkg.com/array-from/-/array-from-2.1.1.tgz#cfe9d8c26628b9dc5aecc62a9f5d8f1f352c1195\"\n+array-union@^2.1.0:\n+ version \"2.1.0\"\n+ resolved \"https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d\"\n+ integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==\n+\nasn1.js@^4.0.0:\nversion \"4.10.1\"\nresolved \"https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0\"\n@@ -317,6 +362,13 @@ brace-expansion@^1.1.7:\nbalanced-match \"^1.0.0\"\nconcat-map \"0.0.1\"\n+braces@^3.0.1:\n+ version \"3.0.2\"\n+ resolved \"https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107\"\n+ integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==\n+ dependencies:\n+ fill-range \"^7.0.1\"\n+\nbrorand@^1.0.1:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f\"\n@@ -405,6 +457,11 @@ caching-transform@^3.0.2:\npackage-hash \"^3.0.0\"\nwrite-file-atomic \"^2.4.2\"\n+call-me-maybe@^1.0.1:\n+ version \"1.0.1\"\n+ resolved \"https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b\"\n+ integrity sha1-JtII6onje1y95gJQoV8DHBak1ms=\n+\ncallsites@^3.0.0:\nversion \"3.1.0\"\nresolved \"https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73\"\n@@ -493,6 +550,16 @@ [email protected]:\nversion \"1.1.3\"\nresolved \"https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25\"\n+command-line-args@^5.1.1:\n+ version \"5.1.1\"\n+ resolved \"https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.1.1.tgz#88e793e5bb3ceb30754a86863f0401ac92fd369a\"\n+ integrity sha512-hL/eG8lrll1Qy1ezvkant+trihbGnaKaeEjj6Scyr3DN+RC7iQ5Rz84IeLERfAWDGo0HBSNAakczwgCilDXnWg==\n+ dependencies:\n+ array-back \"^3.0.1\"\n+ find-replace \"^3.0.0\"\n+ lodash.camelcase \"^4.3.0\"\n+ typical \"^4.0.0\"\n+\ncommander@^2.20.0, commander@~2.20.3:\nversion \"2.20.3\"\nresolved \"https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33\"\n@@ -579,6 +646,15 @@ cross-spawn@^6.0.5:\nshebang-command \"^1.2.0\"\nwhich \"^1.2.9\"\n+cross-spawn@^7.0.1:\n+ version \"7.0.1\"\n+ resolved \"https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.1.tgz#0ab56286e0f7c24e153d04cc2aa027e43a9a5d14\"\n+ integrity sha512-u7v4o84SwFpD32Z8IIcPZ6z1/ie24O6RU3RbtL5Y316l3KuHVPx9ItBgWQ6VlfAFnRnTtMUrsQ9MUUTuEZjogg==\n+ dependencies:\n+ path-key \"^3.1.0\"\n+ shebang-command \"^2.0.0\"\n+ which \"^2.0.1\"\n+\ncrypt@~0.0.1:\nversion \"0.0.2\"\nresolved \"https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b\"\n@@ -660,6 +736,16 @@ des.js@^1.0.0:\ninherits \"^2.0.1\"\nminimalistic-assert \"^1.0.0\"\n+detect-indent@^6.0.0:\n+ version \"6.0.0\"\n+ resolved \"https://registry.yarnpkg.com/detect-indent/-/detect-indent-6.0.0.tgz#0abd0f549f69fc6659a254fe96786186b6f528fd\"\n+ integrity sha512-oSyFlqaTHCItVRGK5RmrmjB+CmaMOW7IaNA/kdxqhoa6d17j/5ce9O9eWXmV/KEdRwqpQA+Vqe8a8Bsybu4YnA==\n+\n+detect-newline@^3.0.0:\n+ version \"3.1.0\"\n+ resolved \"https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651\"\n+ integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==\n+\[email protected], diff@^3.5.0:\nversion \"3.5.0\"\nresolved \"https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12\"\n@@ -676,6 +762,13 @@ diffie-hellman@^5.0.0:\nmiller-rabin \"^4.0.0\"\nrandombytes \"^2.0.0\"\n+dir-glob@^3.0.1:\n+ version \"3.0.1\"\n+ resolved \"https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f\"\n+ integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==\n+ dependencies:\n+ path-type \"^4.0.0\"\n+\ndoctrine@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961\"\n@@ -877,6 +970,16 @@ external-editor@^3.0.3:\niconv-lite \"^0.4.24\"\ntmp \"^0.0.33\"\n+ez-spawn@^2.1.6:\n+ version \"2.1.6\"\n+ resolved \"https://registry.yarnpkg.com/ez-spawn/-/ez-spawn-2.1.6.tgz#e6343ba59f9ef6f32396e53427876d7a4b5fa539\"\n+ integrity sha512-SXH+o93DtsKug2tUB+iySoNw0TBCwAUGGiQr6f+1uMULPETKEd4Y7iSk3FgQwUo27Umz0wpkfEKbNEueILWzYQ==\n+ dependencies:\n+ call-me-maybe \"^1.0.1\"\n+ cross-spawn \"^7.0.1\"\n+ string-argv \"^0.3.1\"\n+ type-detect \"^4.0.8\"\n+\nfast-deep-equal@^2.0.1:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49\"\n@@ -885,6 +988,17 @@ fast-diff@^1.1.2:\nversion \"1.2.0\"\nresolved \"https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03\"\n+fast-glob@^3.0.3:\n+ version \"3.1.1\"\n+ resolved \"https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.1.1.tgz#87ee30e9e9f3eb40d6f254a7997655da753d7c82\"\n+ integrity sha512-nTCREpBY8w8r+boyFYAx21iL6faSsQynliPHM4Uf56SbkyohCNxpVPEH9xrF5TXKy+IsjkPUHDKiUkzBVRXn9g==\n+ dependencies:\n+ \"@nodelib/fs.stat\" \"^2.0.2\"\n+ \"@nodelib/fs.walk\" \"^1.2.3\"\n+ glob-parent \"^5.1.0\"\n+ merge2 \"^1.3.0\"\n+ micromatch \"^4.0.2\"\n+\nfast-json-stable-stringify@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2\"\n@@ -893,6 +1007,13 @@ fast-levenshtein@~2.0.6:\nversion \"2.0.6\"\nresolved \"https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917\"\n+fastq@^1.6.0:\n+ version \"1.6.0\"\n+ resolved \"https://registry.yarnpkg.com/fastq/-/fastq-1.6.0.tgz#4ec8a38f4ac25f21492673adb7eae9cfef47d1c2\"\n+ integrity sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==\n+ dependencies:\n+ reusify \"^1.0.0\"\n+\nfigures@^3.0.0:\nversion \"3.1.0\"\nresolved \"https://registry.yarnpkg.com/figures/-/figures-3.1.0.tgz#4b198dd07d8d71530642864af2d45dd9e459c4ec\"\n@@ -905,6 +1026,13 @@ file-entry-cache@^5.0.1:\ndependencies:\nflat-cache \"^2.0.1\"\n+fill-range@^7.0.1:\n+ version \"7.0.1\"\n+ resolved \"https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40\"\n+ integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==\n+ dependencies:\n+ to-regex-range \"^5.0.1\"\n+\nfind-cache-dir@^2.1.0:\nversion \"2.1.0\"\nresolved \"https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7\"\n@@ -921,6 +1049,13 @@ find-cache-dir@^3.0.0:\nmake-dir \"^3.0.0\"\npkg-dir \"^4.1.0\"\n+find-replace@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38\"\n+ integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==\n+ dependencies:\n+ array-back \"^3.0.1\"\n+\[email protected], find-up@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73\"\n@@ -1001,7 +1136,7 @@ get-stdin@^6.0.0:\nversion \"6.0.0\"\nresolved \"https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b\"\n-glob-parent@^5.0.0:\n+glob-parent@^5.0.0, glob-parent@^5.1.0:\nversion \"5.1.0\"\nresolved \"https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2\"\ndependencies:\n@@ -1039,6 +1174,20 @@ globals@^12.1.0:\ndependencies:\ntype-fest \"^0.8.1\"\n+globby@^10.0.1:\n+ version \"10.0.1\"\n+ resolved \"https://registry.yarnpkg.com/globby/-/globby-10.0.1.tgz#4782c34cb75dd683351335c5829cc3420e606b22\"\n+ integrity sha512-sSs4inE1FB2YQiymcmTv6NWENryABjUNPeWhOvmn4SjtKybglsyPZxFB3U1/+L1bYi0rNZDqCLlHyLYDl1Pq5A==\n+ dependencies:\n+ \"@types/glob\" \"^7.1.1\"\n+ array-union \"^2.1.0\"\n+ dir-glob \"^3.0.1\"\n+ fast-glob \"^3.0.3\"\n+ glob \"^7.1.3\"\n+ ignore \"^5.1.1\"\n+ merge2 \"^1.2.3\"\n+ slash \"^3.0.0\"\n+\ngraceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0:\nversion \"4.2.3\"\nresolved \"https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423\"\n@@ -1138,6 +1287,11 @@ ignore@^4.0.6:\nversion \"4.0.6\"\nresolved \"https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc\"\n+ignore@^5.1.1:\n+ version \"5.1.4\"\n+ resolved \"https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf\"\n+ integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==\n+\nimport-fresh@^3.0.0:\nversion \"3.2.1\"\nresolved \"https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66\"\n@@ -1228,6 +1382,11 @@ is-module@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591\"\n+is-number@^7.0.0:\n+ version \"7.0.0\"\n+ resolved \"https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b\"\n+ integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==\n+\nis-object@~0.1.2:\nversion \"0.1.2\"\nresolved \"https://registry.yarnpkg.com/is-object/-/is-object-0.1.2.tgz#00efbc08816c33cfc4ac8251d132e10dc65098d7\"\n@@ -1481,6 +1640,11 @@ locate-path@^5.0.0:\ndependencies:\np-locate \"^4.1.0\"\n+lodash.camelcase@^4.3.0:\n+ version \"4.3.0\"\n+ resolved \"https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6\"\n+ integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY=\n+\nlodash.flattendeep@^4.4.0:\nversion \"4.4.0\"\nresolved \"https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2\"\n@@ -1499,6 +1663,13 @@ [email protected]:\ndependencies:\nchalk \"^2.0.1\"\n+log-symbols@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4\"\n+ integrity sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==\n+ dependencies:\n+ chalk \"^2.4.2\"\n+\nlolex@^4.1.0, lolex@^4.2.0:\nversion \"4.2.0\"\nresolved \"https://registry.yarnpkg.com/lolex/-/lolex-4.2.0.tgz#ddbd7f6213ca1ea5826901ab1222b65d714b3cd7\"\n@@ -1571,6 +1742,19 @@ merge-stream@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60\"\n+merge2@^1.2.3, merge2@^1.3.0:\n+ version \"1.3.0\"\n+ resolved \"https://registry.yarnpkg.com/merge2/-/merge2-1.3.0.tgz#5b366ee83b2f1582c48f87e47cf1a9352103ca81\"\n+ integrity sha512-2j4DAdlBOkiSZIsaXk4mTE3sRS02yBHAtfy127xRV3bQUFqXkjHCHLW6Scv7DwNRbIWNHH8zpnz9zMaKXIdvYw==\n+\n+micromatch@^4.0.2:\n+ version \"4.0.2\"\n+ resolved \"https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.2.tgz#4fcb0999bf9fbc2fcbdd212f6d629b9a56c39259\"\n+ integrity sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==\n+ dependencies:\n+ braces \"^3.0.1\"\n+ picomatch \"^2.0.5\"\n+\nmiller-rabin@^4.0.0:\nversion \"4.0.1\"\nresolved \"https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d\"\n@@ -1900,6 +2084,11 @@ path-key@^2.0.1:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40\"\n+path-key@^3.1.0:\n+ version \"3.1.1\"\n+ resolved \"https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375\"\n+ integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==\n+\npath-parse@^1.0.6:\nversion \"1.0.6\"\nresolved \"https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c\"\n@@ -1916,6 +2105,11 @@ path-type@^3.0.0:\ndependencies:\npify \"^3.0.0\"\n+path-type@^4.0.0:\n+ version \"4.0.0\"\n+ resolved \"https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b\"\n+ integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==\n+\npathval@^1.1.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0\"\n@@ -1930,6 +2124,11 @@ pbkdf2@^3.0.3:\nsafe-buffer \"^5.0.1\"\nsha.js \"^2.4.8\"\n+picomatch@^2.0.5:\n+ version \"2.1.1\"\n+ resolved \"https://registry.yarnpkg.com/picomatch/-/picomatch-2.1.1.tgz#ecdfbea7704adb5fe6fb47f9866c4c0e15e905c5\"\n+ integrity sha512-OYMyqkKzK7blWO/+XZYP6w8hH0LDvkBvdvKukti+7kqYFCiEAk+gI3DWnryapc0Dau05ugGTy0foQ6mqn4AHYA==\n+\npify@^3.0.0:\nversion \"3.0.0\"\nresolved \"https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176\"\n@@ -2120,6 +2319,11 @@ restore-cursor@^3.1.0:\nonetime \"^5.1.0\"\nsignal-exit \"^3.0.2\"\n+reusify@^1.0.0:\n+ version \"1.0.4\"\n+ resolved \"https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76\"\n+ integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==\n+\[email protected]:\nversion \"2.6.3\"\nresolved \"https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab\"\n@@ -2231,6 +2435,11 @@ run-async@^2.2.0:\ndependencies:\nis-promise \"^2.1.0\"\n+run-parallel@^1.1.9:\n+ version \"1.1.9\"\n+ resolved \"https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679\"\n+ integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==\n+\nrxjs@^6.4.0:\nversion \"6.5.3\"\nresolved \"https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.3.tgz#510e26317f4db91a7eb1de77d9dd9ba0a4899a3a\"\n@@ -2282,10 +2491,22 @@ shebang-command@^1.2.0:\ndependencies:\nshebang-regex \"^1.0.0\"\n+shebang-command@^2.0.0:\n+ version \"2.0.0\"\n+ resolved \"https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea\"\n+ integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==\n+ dependencies:\n+ shebang-regex \"^3.0.0\"\n+\nshebang-regex@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3\"\n+shebang-regex@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172\"\n+ integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==\n+\nshelljs@^0.8.3:\nversion \"0.8.3\"\nresolved \"https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.3.tgz#a7f3319520ebf09ee81275b2368adb286659b097\"\n@@ -2310,6 +2531,11 @@ sinon@^7.5.0:\nnise \"^1.5.2\"\nsupports-color \"^5.5.0\"\n+slash@^3.0.0:\n+ version \"3.0.0\"\n+ resolved \"https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634\"\n+ integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==\n+\nslice-ansi@^2.1.0:\nversion \"2.1.0\"\nresolved \"https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636\"\n@@ -2388,6 +2614,11 @@ sprintf-js@~1.0.2:\nversion \"1.0.3\"\nresolved \"https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c\"\n+string-argv@^0.3.1:\n+ version \"0.3.1\"\n+ resolved \"https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da\"\n+ integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==\n+\nstring-range@~1.2, string-range@~1.2.1:\nversion \"1.2.2\"\nresolved \"https://registry.yarnpkg.com/string-range/-/string-range-1.2.2.tgz#a893ed347e72299bc83befbbf2a692a8d239d5dd\"\n@@ -2539,6 +2770,13 @@ to-fast-properties@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e\"\n+to-regex-range@^5.0.1:\n+ version \"5.0.1\"\n+ resolved \"https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4\"\n+ integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==\n+ dependencies:\n+ is-number \"^7.0.0\"\n+\nts-node@^8.5.4:\nversion \"8.5.4\"\nresolved \"https://registry.yarnpkg.com/ts-node/-/ts-node-8.5.4.tgz#a152add11fa19c221d0b48962c210cf467262ab2\"\n@@ -2565,7 +2803,7 @@ type-check@~0.3.2:\ndependencies:\nprelude-ls \"~1.1.2\"\[email protected], type-detect@^4.0.0, type-detect@^4.0.5:\[email protected], type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8:\nversion \"4.0.8\"\nresolved \"https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c\"\n@@ -2610,6 +2848,11 @@ [email protected], typescript@^3.7.2:\nversion \"3.7.2\"\nresolved \"https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb\"\n+typical@^4.0.0:\n+ version \"4.0.0\"\n+ resolved \"https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4\"\n+ integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==\n+\nuglify-js@^3.1.4:\nversion \"3.7.1\"\nresolved \"https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.7.1.tgz#35c7de17971a4aa7689cd2eae0a5b39bb838c0c5\"\n@@ -2658,6 +2901,20 @@ validate-npm-package-license@^3.0.1:\nspdx-correct \"^3.0.0\"\nspdx-expression-parse \"^3.0.0\"\n+version-bump-prompt@^5.0.6:\n+ version \"5.0.6\"\n+ resolved \"https://registry.yarnpkg.com/version-bump-prompt/-/version-bump-prompt-5.0.6.tgz#71fb464316645253ba3f301fffd4804d8924ad75\"\n+ integrity sha512-pjMmyngPdof9jZ0Jye9JAz7BNiqszeqIAjYcUx/0DdUmfw6LOAsJsfU5yIj4+LOVIet6chFANIeQBc1CKEbZZQ==\n+ dependencies:\n+ command-line-args \"^5.1.1\"\n+ detect-indent \"^6.0.0\"\n+ detect-newline \"^3.0.0\"\n+ ez-spawn \"^2.1.6\"\n+ globby \"^10.0.1\"\n+ inquirer \"^7.0.0\"\n+ log-symbols \"^3.0.0\"\n+ semver \"^6.3.0\"\n+\nwhich-module@^2.0.0:\nversion \"2.0.0\"\nresolved \"https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a\"\n@@ -2668,6 +2925,13 @@ [email protected], which@^1.2.9, which@^1.3.0:\ndependencies:\nisexe \"^2.0.0\"\n+which@^2.0.1:\n+ version \"2.0.2\"\n+ resolved \"https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1\"\n+ integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==\n+ dependencies:\n+ isexe \"^2.0.0\"\n+\[email protected]:\nversion \"1.1.3\"\nresolved \"https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457\"\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: bump version to 0.1.0
305,159
16.12.2019 12:40:09
-3,600
cc20a0f46d9b5f64644f7a05af27b9036202dbd9
chore: rename member to better match semantics
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -18,7 +18,7 @@ class WriteBuffer {\nmessage?: string = undefined\nconstructor(\n- private maxRecords: number,\n+ private maxChunkRecords: number,\nprivate flushFn: (message: string) => Promise<void>,\nprivate scheduleSend: () => void\n) {}\n@@ -31,7 +31,7 @@ class WriteBuffer {\nthis.message = this.message + '\\n' + record\n}\nthis.length++\n- if (this.length >= this.maxRecords) {\n+ if (this.length >= this.maxChunkRecords) {\nthis.flush().catch(_e => {\n// an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: rename member to better match semantics
305,159
16.12.2019 13:16:27
-3,600
c40144beb52bb7c112c9f7060468bdf805191351
chore: change impl for refactoring
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -5,6 +5,7 @@ import {\nClientOptions,\nDEFAULT_ConnectionOptions,\nPointSettings,\n+ WriteOptions,\n} from '../options'\nimport {Transport, SendOptions} from '../transport'\nimport Logger from './Logger'\n@@ -58,48 +59,77 @@ class WriteBuffer {\nexport default class WriteApiImpl implements WriteApi, PointSettings {\nprivate buffer: WriteBuffer\nprivate closed = false\n-\n+ private httpPath: string\n+ private writeOptions: WriteOptions\n+ private sendOptions: Partial<SendOptions> = {\n+ method: 'POST',\n+ maxRetries: 0, // we control manual retry attempts\n+ headers: {\n+ 'content-type': 'text/plain; charset=utf-8',\n+ },\n+ }\n+ private retryJitter: number\nprivate _timeoutHandle: any = undefined\nprivate currentTime: () => string\nconstructor(\n- transport: Transport,\n+ private transport: Transport,\norg: string,\nbucket: string,\nprecision: WritePrecision,\nclientOptions: ClientOptions\n) {\n- const httpPath = `/api/v2/write?org=${encodeURIComponent(\n+ this.httpPath = `/api/v2/write?org=${encodeURIComponent(\norg\n)}&bucket=${encodeURIComponent(bucket)}&precision=${precision}`\n- const writeOptions = {\n+ this.writeOptions = {\n...DEFAULT_WriteOptions,\n...clientOptions.writeOptions,\n}\nthis.currentTime = currentTime[precision]\n- const sendOptions: Partial<SendOptions> = {\n- method: 'POST',\n- maxRetries: 0, // we control manual retry attempts\n- headers: {\n- 'content-type': 'text/plain; charset=utf-8',\n- },\n- }\n- const retryJitter =\n+\n+ this.retryJitter =\nclientOptions.retryJitter !== undefined\n? clientOptions.retryJitter\n: (DEFAULT_ConnectionOptions.retryJitter as number)\n- /** sendBatch uses scheduleNextSend and vice versa */\n- // eslint-disable-next-line @typescript-eslint/no-this-alias\n- const self = this\n- const sendBatch = (\n+ const scheduleNextSend = (): void => {\n+ if (this.writeOptions.flushInterval > 0) {\n+ this._clearFlushTimeout()\n+ /* istanbul ignore else manually reviewed, hard to reproduce */\n+ if (!this.closed) {\n+ this._timeoutHandle = setTimeout(\n+ () =>\n+ this.sendBatch(\n+ this.buffer.reset(),\n+ this.writeOptions.maxRetries\n+ ).catch(_e => {\n+ // an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n+ }),\n+ this.writeOptions.flushInterval\n+ )\n+ }\n+ }\n+ }\n+ this.buffer = new WriteBuffer(\n+ this.writeOptions.batchSize,\n+ message => {\n+ this._clearFlushTimeout()\n+ return this.sendBatch(message, this.writeOptions.maxRetries)\n+ },\n+ scheduleNextSend\n+ )\n+ }\n+\n+ sendBatch(\nmessage: string | undefined,\nretryCountdown: number\n- ): Promise<void> => {\n+ ): Promise<void> {\n+ // eslint-disable-next-line @typescript-eslint/no-this-alias\n+ const self: WriteApiImpl = this\nif (!this.closed && message) {\nreturn new Promise<void>((resolve, reject) => {\n- // TODO monitor and limit pending writes\n- transport.send(httpPath, message, sendOptions, {\n+ this.transport.send(this.httpPath, message, this.sendOptions, {\nerror(error: Error): void {\nif (\n!self.closed &&\n@@ -113,10 +143,11 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n)\nself._scheduleRetry(\n() =>\n- sendBatch(message, retryCountdown - 1)\n+ self\n+ .sendBatch(message, retryCountdown - 1)\n.then(resolve)\n.catch(reject),\n- getRetryDelay(error, retryJitter)\n+ getRetryDelay(error, self.retryJitter)\n)\n} else {\nLogger.error(`Write to influx DB failed.`, error)\n@@ -132,32 +163,6 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nreturn Promise.resolve()\n}\n}\n- const scheduleNextSend = (): void => {\n- if (writeOptions.flushInterval > 0) {\n- this._clearFlushTimeout()\n- /* istanbul ignore else manually reviewed, hard to reproduce */\n- if (!this.closed) {\n- this._timeoutHandle = setTimeout(\n- () =>\n- sendBatch(this.buffer.reset(), writeOptions.maxRetries).catch(\n- _e => {\n- // an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n- }\n- ),\n- writeOptions.flushInterval\n- )\n- }\n- }\n- }\n- this.buffer = new WriteBuffer(\n- writeOptions.batchSize,\n- message => {\n- this._clearFlushTimeout()\n- return sendBatch(message, writeOptions.maxRetries)\n- },\n- scheduleNextSend\n- )\n- }\nprivate _clearFlushTimeout(): void {\nif (this._timeoutHandle !== undefined) {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: change impl for refactoring
305,159
16.12.2019 13:58:34
-3,600
36590bc07741bcf477bb163c8e9dd76335c75cd2
feat: allow to queue retries in lines
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -16,21 +16,21 @@ import {currentTime} from '../util/currentTime'\nclass WriteBuffer {\nlength = 0\n- message?: string = undefined\n+ message: string[]\nconstructor(\nprivate maxChunkRecords: number,\n- private flushFn: (message: string) => Promise<void>,\n+ private flushFn: (lines: string[]) => Promise<void>,\nprivate scheduleSend: () => void\n- ) {}\n+ ) {\n+ this.message = new Array<string>(maxChunkRecords)\n+ }\nadd(record: string): void {\nif (this.length === 0) {\n- this.message = record\nthis.scheduleSend()\n- } else {\n- this.message = this.message + '\\n' + record\n}\n+ this.message[this.length] = record\nthis.length++\nif (this.length >= this.maxChunkRecords) {\nthis.flush().catch(_e => {\n@@ -39,20 +39,17 @@ class WriteBuffer {\n}\n}\nflush(): Promise<void> {\n- const message = this.reset()\n- if (message) {\n- return this.flushFn(message)\n+ const lines = this.reset()\n+ if (lines.length > 0) {\n+ return this.flushFn(lines)\n} else {\nreturn Promise.resolve()\n}\n}\n- reset(): string | undefined {\n- const message = this.message\n- if (message) {\n- this.message = undefined\n+ reset(): string[] {\n+ const retVal = this.message.slice(0, this.length)\nthis.length = 0\n- }\n- return message\n+ return retVal\n}\n}\n@@ -121,15 +118,12 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n)\n}\n- sendBatch(\n- message: string | undefined,\n- retryCountdown: number\n- ): Promise<void> {\n+ sendBatch(lines: string[], retryCountdown: number): Promise<void> {\n// eslint-disable-next-line @typescript-eslint/no-this-alias\nconst self: WriteApiImpl = this\n- if (!this.closed && message) {\n+ if (!this.closed && lines.length > 0) {\nreturn new Promise<void>((resolve, reject) => {\n- this.transport.send(this.httpPath, message, this.sendOptions, {\n+ this.transport.send(this.httpPath, lines.join('\\n'), this.sendOptions, {\nerror(error: Error): void {\nif (\n!self.closed &&\n@@ -141,14 +135,12 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n`Write to influx DB failed (remaining attempts: ${retryCountdown}).`,\nerror\n)\n- self._scheduleRetry(\n- () =>\n- self\n- .sendBatch(message, retryCountdown - 1)\n- .then(resolve)\n- .catch(reject),\n+ self._retry(\n+ lines,\n+ retryCountdown - 1,\ngetRetryDelay(error, self.retryJitter)\n)\n+ reject(error)\n} else {\nLogger.error(`Write to influx DB failed.`, error)\nreject(error)\n@@ -171,11 +163,19 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\n}\n- private _scheduleRetry(fn: () => any, delay: number): void {\n+ private _retry(\n+ lines: string[],\n+ remainingRetries: number,\n+ retryDelay: number\n+ ): void {\n/* istanbul ignore else manually reviewed, hard to reproduce */\nif (!this.closed) {\n// TODO queue, monitor and limit retries, cancel them on close\n- setTimeout(fn, delay)\n+ setTimeout(() => {\n+ this.sendBatch(lines, remainingRetries).catch(() => {\n+ // an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n+ })\n+ }, retryDelay)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -72,8 +72,7 @@ describe('WriteApiImpl', () => {\n.flush()\n.then(() => expect.fail('failure expected'))\n.catch(e => {\n- expect(logs.error).to.length(1)\n- expect(logs.warn).to.length(DEFAULT_WriteOptions.maxRetries)\n+ expect([...logs.error, ...logs.warn]).to.length(1)\nexpect(e).to.be.ok\n})\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: allow to queue retries in lines
305,159
16.12.2019 14:26:52
-3,600
179b147888a79b4e4ddee2669f58a94566bff8a5
fix: exclude default write options from testing
[ { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -4,7 +4,6 @@ import NodeHttpTransport from '../../../src/impl/NodeHttpTransport'\nimport {\nClientOptions,\nWritePrecision,\n- DEFAULT_WriteOptions,\nWriteOptions,\nPoint,\nWriteApi,\n@@ -95,14 +94,14 @@ describe('WriteApiImpl', () => {\ncollectLogging.after()\n})\nit('flushes the data in specified batchSize', async () => {\n- useSubject({flushInterval: 0, batchSize: 1})\n+ useSubject({flushInterval: 0, batchSize: 1, maxRetries: 2})\nsubject.writeRecord('test value=1')\nsubject.writeRecords(['test value=2', 'test value=3'])\n// wait for http calls to finish\nawait new Promise(resolve => setTimeout(resolve, 10))\nawait subject.close().then(() => {\nexpect(logs.error).to.length(3)\n- expect(logs.warn).to.length(3 * DEFAULT_WriteOptions.maxRetries)\n+ expect(logs.warn).to.length(3 * 2)\n})\n})\nit('does not retry write when configured to do so', async () => {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: exclude default write options from testing
305,159
16.12.2019 15:21:44
-3,600
8d941a19a0f90d79f9d82622d8973d7fb75e8e1e
fix(write API): don't retry calls on close
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -201,7 +201,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nreturn this.buffer.flush()\n}\nclose(): Promise<void> {\n- const retVal = this.flush()\n+ const retVal = this.sendBatch(this.buffer.reset(), 0)\nthis.closed = true\nreturn retVal\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix(write API): don't retry calls on close
305,159
16.12.2019 15:48:16
-3,600
c39100f0a33233e5dc51d5456b4ab85c70ea9e96
fix: compute retry delay with optional jitter
[ { "change_type": "MODIFY", "old_path": "src/errors.ts", "new_path": "src/errors.ts", "diff": "@@ -92,18 +92,26 @@ export function canRetryHttpCall(error: any): boolean {\n/**\n* Gets retry delay from the supplied error, possibly using random number up to retryJitter.\n*/\n-export function getRetryDelay(error: Error, retryJitter: number): number {\n+export function getRetryDelay(error: Error, retryJitter?: number): number {\nif (!error) {\nreturn 0\n- } else if (typeof (error as any).retryAfter === 'function') {\n+ } else {\n+ let retVal\n+ if (typeof (error as any).retryAfter === 'function') {\nconst delay = ((error as any).retryAfter as () => number)()\nif (delay < 0) {\n- return 1 + Math.round(Math.random() * retryJitter)\n+ retVal = 1\n} else {\nreturn delay\n}\n} else {\n- return 1 + Math.round(Math.random() * retryJitter)\n+ retVal = 1\n+ }\n+ if (retryJitter && retryJitter > 0) {\n+ return retVal + Math.round(Math.random() * retryJitter)\n+ } else {\n+ return retVal\n+ }\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "@@ -94,9 +94,21 @@ describe('errors', () => {\nit(`retries ${entry.error} in ${\nentry.retryAfter === -1 ? '>=1' : entry.retryAfter\n} ms`, () => {\n- const val = getRetryDelay(entry.error, 1000)\n+ let val = getRetryDelay(entry.error, 1000)\nif (entry.retryAfter === -1) {\n- expect(val).to.be.greaterThan(1)\n+ expect(val).to.not.be.lessThan(1)\n+ } else {\n+ expect(val).to.be.equal(entry.retryAfter)\n+ }\n+ val = getRetryDelay(entry.error, 0)\n+ if (entry.retryAfter === -1) {\n+ expect(val).to.not.be.lessThan(1)\n+ } else {\n+ expect(val).to.be.equal(entry.retryAfter)\n+ }\n+ val = getRetryDelay(entry.error)\n+ if (entry.retryAfter === -1) {\n+ expect(val).to.not.be.lessThan(1)\n} else {\nexpect(val).to.be.equal(entry.retryAfter)\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix: compute retry delay with optional jitter
305,159
16.12.2019 20:58:48
-3,600
12c06113ccb6399b1a00d2b26781a481b25e9ff5
feat: introduce retry buffer
[ { "change_type": "ADD", "old_path": null, "new_path": "src/impl/RetryBuffer.ts", "diff": "+import Logger from './Logger'\n+\n+// TODO create retry options\n+/* minimum time to schedule retry */\n+const MIN_RETRY_DELAY = 100\n+/* interval between successful retries */\n+const RETRY_INTERVAL = 1\n+\n+interface RetryItem {\n+ lines: string[]\n+ retryCount: number\n+ next?: RetryItem\n+}\n+\n+/**\n+ * Retries lines up to a limit of max buffer size.\n+ */\n+export class RetryBuffer {\n+ first?: RetryItem\n+ last?: RetryItem\n+ size = 0\n+ nextRetryTime = 0\n+ closed = false\n+ private _timeoutHandle: any = undefined\n+\n+ constructor(\n+ private maxLines: number,\n+ private jitterDelay: number,\n+ private retryLines: (\n+ lines: string[],\n+ retryCountdown: number\n+ ) => Promise<void>\n+ ) {}\n+\n+ addLines(lines: string[], retryCount: number, delay: number): void {\n+ if (this.closed) return\n+ if (!lines.length) return\n+ const retryTime = Date.now() + delay\n+ if (retryTime > this.nextRetryTime) this.nextRetryTime = retryTime\n+ // ensure at most maxLines ar in the buffer\n+ while (this.first && this.size + lines.length > this.maxLines) {\n+ const newFirst = this.first.next\n+ this.size -= this.first.lines.length\n+ this.first = newFirst\n+ }\n+ const toAdd = {\n+ lines,\n+ retryCount,\n+ }\n+ if (this.last) {\n+ this.last.next = toAdd\n+ this.last = toAdd\n+ } else {\n+ this.first = toAdd\n+ this.last = toAdd\n+ if (!this._timeoutHandle) {\n+ this.scheduleRetry(delay)\n+ }\n+ }\n+ }\n+\n+ removeLines(): RetryItem | undefined {\n+ if (this.first) {\n+ const toRetry = this.first\n+ this.first = this.first.next\n+ this.size -= toRetry.lines.length\n+ if (!this.first) this.last = undefined\n+ return toRetry\n+ }\n+ return undefined\n+ }\n+\n+ scheduleRetry(delay: number): void {\n+ this._timeoutHandle = setTimeout(() => {\n+ const toRetry = this.removeLines()\n+ if (toRetry) {\n+ this.retryLines(toRetry.lines, toRetry.retryCount)\n+ .then(() => {\n+ // continue with successfull retry\n+ this.scheduleRetry(RETRY_INTERVAL)\n+ })\n+ .catch(_e => {\n+ // already logged\n+ this.scheduleRetry(this.nextRetryTime - Date.now())\n+ })\n+ } else {\n+ this._timeoutHandle = undefined\n+ }\n+ }, Math.max(MIN_RETRY_DELAY, delay + Math.random() * this.jitterDelay))\n+ }\n+\n+ async flush(): Promise<void> {\n+ let toRetry\n+ while ((toRetry = this.removeLines())) {\n+ await this.retryLines(toRetry.lines, toRetry.retryCount)\n+ }\n+ }\n+\n+ close(): void {\n+ if (this.size > 0) {\n+ Logger.warn(\n+ `Closing retry buffer, ${this.size} items were not written to InfluxDB!`,\n+ null\n+ )\n+ }\n+ if (this._timeoutHandle) {\n+ clearTimeout(this._timeoutHandle)\n+ this._timeoutHandle = undefined\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -16,21 +16,21 @@ import {currentTime} from '../util/currentTime'\nclass WriteBuffer {\nlength = 0\n- message: string[]\n+ lines: string[]\nconstructor(\nprivate maxChunkRecords: number,\nprivate flushFn: (lines: string[]) => Promise<void>,\nprivate scheduleSend: () => void\n) {\n- this.message = new Array<string>(maxChunkRecords)\n+ this.lines = new Array<string>(maxChunkRecords)\n}\nadd(record: string): void {\nif (this.length === 0) {\nthis.scheduleSend()\n}\n- this.message[this.length] = record\n+ this.lines[this.length] = record\nthis.length++\nif (this.length >= this.maxChunkRecords) {\nthis.flush().catch(_e => {\n@@ -47,7 +47,7 @@ class WriteBuffer {\n}\n}\nreset(): string[] {\n- const retVal = this.message.slice(0, this.length)\n+ const retVal = this.lines.slice(0, this.length)\nthis.length = 0\nreturn retVal\n}\n@@ -110,12 +110,13 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\nthis.buffer = new WriteBuffer(\nthis.writeOptions.batchSize,\n- message => {\n+ lines => {\nthis._clearFlushTimeout()\n- return this.sendBatch(message, this.writeOptions.maxRetries)\n+ return this.sendBatch(lines, this.writeOptions.maxRetries)\n},\nscheduleNextSend\n)\n+ this.sendBatch = this.sendBatch.bind(this)\n}\nsendBatch(lines: string[], retryCountdown: number): Promise<void> {\n" }, { "change_type": "MODIFY", "old_path": "src/options.ts", "new_path": "src/options.ts", "diff": "@@ -27,15 +27,19 @@ export const DEFAULT_ConnectionOptions: Partial<ConnectionOptions> = {\nexport interface WriteOptions {\n/** max number of records to send in a batch */\nbatchSize: number\n- /** delay between data flushes in milliseconds, at most batch size records are sent during flush */\n+ /** delay between data flushes in milliseconds, at most `batch size` records are sent during flush */\nflushInterval: number\n/** max number of retries when write fails */\nmaxRetries: number\n+ /** the maximum size of retry-buffer (in lines) */\n+ retryBufferLines: number\n}\nexport const DEFAULT_WriteOptions: WriteOptions = Object.freeze({\nbatchSize: 1000,\nflushInterval: 60000,\nmaxRetries: 2,\n+ // size of the retry-buffer (in lines)\n+ retryBufferLines: 32_000,\n})\nexport interface ClientOptions extends ConnectionOptions {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: introduce retry buffer
305,159
17.12.2019 14:41:29
-3,600
9c0ac3167665797f23d81eae4242536d4ed94ecf
feat: introduce retry strategy
[ { "change_type": "MODIFY", "old_path": "src/errors.ts", "new_path": "src/errors.ts", "diff": "export interface RetriableDecision {\ncanRetry(): boolean\n/**\n- * Get the delay in millisecond to retry the action. Can return negative number\n- * to let the implementation decide the delay.\n+ * Get the delay in milliseconds to retry the action.\n+ * @return 0 to let the implementation decide, miliseconds delay otherwise\n*/\nretryAfter(): number\n}\n@@ -48,10 +48,10 @@ export class HttpError extends Error implements RetriableDecision {\nif (/^[0-9]+$/.test(retryAfter)) {\nthis._retryAfter = parseInt(retryAfter)\n} else {\n- this._retryAfter = -1\n+ this._retryAfter = 0\n}\n} else {\n- this._retryAfter = -1\n+ this._retryAfter = 0\n}\n}\n@@ -92,20 +92,15 @@ export function canRetryHttpCall(error: any): boolean {\n/**\n* Gets retry delay from the supplied error, possibly using random number up to retryJitter.\n*/\n-export function getRetryDelay(error: Error, retryJitter?: number): number {\n+export function getRetryDelay(error?: Error, retryJitter?: number): number {\nif (!error) {\nreturn 0\n} else {\nlet retVal\nif (typeof (error as any).retryAfter === 'function') {\n- const delay = ((error as any).retryAfter as () => number)()\n- if (delay < 0) {\n- retVal = 1\n+ return ((error as any).retryAfter as () => number)()\n} else {\n- return delay\n- }\n- } else {\n- retVal = 1\n+ retVal = 0\n}\nif (retryJitter && retryJitter > 0) {\nreturn retVal + Math.round(Math.random() * retryJitter)\n@@ -126,7 +121,7 @@ export class RequestTimedOutError extends Error implements RetriableDecision {\nreturn true\n}\nretryAfter(): number {\n- return -1\n+ return 0\n}\n}\n@@ -141,6 +136,6 @@ export class ResponseAbortedError extends Error implements RetriableDecision {\nreturn true\n}\nretryAfter(): number {\n- return -1\n+ return 0\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/impl/RetryStrategy.ts", "diff": "+import {getRetryDelay} from '../errors'\n+\n+/**\n+ * Represents a strategy for calculating retry delays.\n+ */\n+export default interface RetryStrategy {\n+ nextDelay(error?: Error): number\n+ success(): void\n+}\n+\n+export interface BuiltinStrategyOptions {\n+ retryJitter: number\n+ minDelay: number\n+ maxDelay: number\n+}\n+\n+export const DEFAULT_BuiltinStrategyConfig: BuiltinStrategyOptions = {\n+ retryJitter: 500,\n+ minDelay: 1000,\n+ maxDelay: 15000,\n+}\n+\n+/**\n+ * Applies a variant of exponential backoff with initial max delay with a random\n+ * jitter delay and repects alsi retry after settings of supplied errors.\n+ */\n+export class RetryStrategyImpl implements RetryStrategy {\n+ options: BuiltinStrategyOptions\n+ currentDelay: number | undefined\n+\n+ constructor(options?: Partial<BuiltinStrategyOptions>) {\n+ this.options = {...DEFAULT_BuiltinStrategyConfig, ...options}\n+ this.success()\n+ }\n+\n+ nextDelay(error?: Error): number {\n+ const delay = getRetryDelay(error)\n+ if (delay && delay > 0) {\n+ return Math.min(\n+ delay + Math.round(Math.random() * this.options.retryJitter),\n+ this.options.maxDelay\n+ )\n+ } else {\n+ if (this.currentDelay) {\n+ this.currentDelay = Math.min(\n+ Math.max(this.currentDelay * 2, 1) +\n+ Math.round(Math.random() * this.options.retryJitter),\n+ this.options.maxDelay\n+ )\n+ } else {\n+ this.currentDelay =\n+ this.options.minDelay +\n+ Math.round(Math.random() * this.options.retryJitter)\n+ }\n+ return this.currentDelay\n+ }\n+ }\n+ success(): void {\n+ this.currentDelay = undefined\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "@@ -27,7 +27,7 @@ describe('errors', () => {\nit('retries ' + error, () => {\nexpect(canRetryHttpCall(error)).to.be.true\nif (error instanceof HttpError) {\n- expect(error.retryAfter()).to.be.equal(-1)\n+ expect(error.retryAfter()).to.be.equal(0)\n}\n})\n})\n@@ -52,8 +52,8 @@ describe('errors', () => {\nretryAfter: 10,\n},\n,\n- {error: new RequestTimedOutError(), retryAfter: -1},\n- {error: new ResponseAbortedError(), retryAfter: -1},\n+ {error: new RequestTimedOutError(), retryAfter: 0},\n+ {error: new ResponseAbortedError(), retryAfter: 0},\n]\ntestSet.forEach(entry => {\nit(`retries ${entry.error} in ${entry.retryAfter} ms`, () => {\n@@ -83,9 +83,9 @@ describe('errors', () => {\nretryAfter: 10,\n},\n,\n- {error: new RequestTimedOutError(), retryAfter: -1},\n- {error: new ResponseAbortedError(), retryAfter: -1},\n- {error: new Error(), retryAfter: -1},\n+ {error: new RequestTimedOutError(), retryAfter: 0},\n+ {error: new ResponseAbortedError(), retryAfter: 0},\n+ {error: new Error(), retryAfter: 0},\n{error: '', retryAfter: 0},\n{error: null, retryAfter: 0},\n{error: undefined, retryAfter: 0},\n@@ -95,23 +95,15 @@ describe('errors', () => {\nentry.retryAfter === -1 ? '>=1' : entry.retryAfter\n} ms`, () => {\nlet val = getRetryDelay(entry.error, 1000)\n- if (entry.retryAfter === -1) {\n- expect(val).to.not.be.lessThan(1)\n+ if (entry.retryAfter === 0) {\n+ expect(val).to.not.be.lessThan(0)\n} else {\nexpect(val).to.be.equal(entry.retryAfter)\n}\nval = getRetryDelay(entry.error, 0)\n- if (entry.retryAfter === -1) {\n- expect(val).to.not.be.lessThan(1)\n- } else {\nexpect(val).to.be.equal(entry.retryAfter)\n- }\nval = getRetryDelay(entry.error)\n- if (entry.retryAfter === -1) {\n- expect(val).to.not.be.lessThan(1)\n- } else {\nexpect(val).to.be.equal(entry.retryAfter)\n- }\n})\n})\n})\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/impl/RetryStrategy.test.ts", "diff": "+import {expect} from 'chai'\n+import {RetryStrategyImpl} from '../../../src/impl/RetryStrategy'\n+import {HttpError} from '../../../src'\n+\n+describe('RetryStrategyImpl', () => {\n+ it('generates exponential data from min to max for unknown delays', () => {\n+ const subject = new RetryStrategyImpl({\n+ minDelay: 100,\n+ maxDelay: 1000,\n+ retryJitter: 0,\n+ })\n+ const values = [1, 2, 3, 4, 5, 6].reduce((acc, _val) => {\n+ acc.push(subject.nextDelay())\n+ return acc\n+ }, [] as number[])\n+ expect(values).to.be.deep.equal([100, 200, 400, 800, 1000, 1000])\n+ subject.success()\n+ expect(subject.nextDelay()).equals(100)\n+ })\n+ it('generates the delays according to errors', () => {\n+ const subject = new RetryStrategyImpl({\n+ minDelay: 100,\n+ maxDelay: 1000,\n+ retryJitter: 0,\n+ })\n+ const values = [1, 2, 3, 4, 5, 6].reduce((acc, val) => {\n+ acc.push(subject.nextDelay(new HttpError(503, '', '', String(val))))\n+ return acc\n+ }, [] as number[])\n+ expect(values).to.be.deep.equal([1, 2, 3, 4, 5, 6])\n+ })\n+ it('generates jittered delays according to error delay', () => {\n+ const subject = new RetryStrategyImpl({\n+ minDelay: 100,\n+ maxDelay: 1000,\n+ retryJitter: 10,\n+ })\n+ const values = [1, 2, 3, 4, 5, 6].reduce((acc, val) => {\n+ acc.push(subject.nextDelay(new HttpError(503, '', '', String(val))))\n+ return acc\n+ }, [] as number[])\n+ expect(values).to.have.length(6)\n+ values.forEach((x, i) => {\n+ expect(x).to.not.be.lessThan(i + 1)\n+ expect(x).to.not.be.greaterThan(1000)\n+ })\n+ })\n+ it('generates default jittered delays', () => {\n+ const subject = new RetryStrategyImpl({\n+ minDelay: 100,\n+ maxDelay: 1000,\n+ retryJitter: 10,\n+ })\n+ const values = [1, 2, 3, 4, 5, 6].reduce((acc, val) => {\n+ acc.push(subject.nextDelay())\n+ return acc\n+ }, [] as number[])\n+ expect(values).to.have.length(6)\n+ values.forEach((x, i) => {\n+ expect(x).to.not.be.lessThan(i)\n+ expect(x).to.not.be.greaterThan(1000)\n+ if (i > 0) {\n+ expect(x).to.not.be.lessThan(values[i - 1])\n+ }\n+ })\n+ })\n+})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: introduce retry strategy
305,159
17.12.2019 14:55:57
-3,600
09afec2928e687ff1a25b6b99b7db9d6cf5b6def
feat(retry): use retry strategy in node transport
[ { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -7,11 +7,11 @@ import {\nRequestTimedOutError,\nResponseAbortedError,\ncanRetryHttpCall,\n- getRetryDelay,\nHttpError,\n} from '../errors'\nimport {CommunicationObserver, Transport, SendOptions} from '../transport'\nimport Cancellable from '../util/Cancellable'\n+import {RetryStrategy, RetryStrategyImpl} from './retryStrategy'\nclass CancellableImpl implements Cancellable {\nprivate cancelled = false\n@@ -37,12 +37,11 @@ class CancellableImpl implements Cancellable {\n*/\nexport class NodeHttpTransport implements Transport {\nprivate defaultOptions: {[key: string]: any}\n- private retryJitter: number\nprivate requestApi: (\noptions: http.RequestOptions,\ncallback: (res: http.IncomingMessage) => void\n) => http.ClientRequest\n-\n+ retryStrategy: RetryStrategy\n/**\n* Creates a node transport using for the client options supplied.\n* @param connectionOptions client options\n@@ -57,8 +56,9 @@ export class NodeHttpTransport implements Transport {\nprotocol: url.protocol,\nhostname: url.hostname,\n}\n- this.retryJitter =\n+ const retryJitter =\nthis.defaultOptions.retryJitter > 0 ? this.defaultOptions.retryJitter : 0\n+ this.retryStrategy = new RetryStrategyImpl({retryJitter})\nif (url.protocol === 'http:') {\nthis.requestApi = http.request\n} else if (url.protocol === 'https:') {\n@@ -228,7 +228,7 @@ export class NodeHttpTransport implements Transport {\nrequestMessage.retries = retries + 1\nconst cancelHandle = setTimeout(\n() => this.request(requestMessage, cancellable, callbacks),\n- getRetryDelay(error, this.retryJitter)\n+ this.retryStrategy.nextDelay(error)\n)\ncancellable.addCancelableAction(() => {\n/* istanbul ignore next safety check */\n@@ -244,6 +244,7 @@ export class NodeHttpTransport implements Transport {\n},\ncomplete: (): void => {\nif (state === 0) {\n+ this.retryStrategy.success()\nstate = 2\n/* istanbul ignore else safety check */\nif (callbacks.complete) callbacks.complete()\n" }, { "change_type": "RENAME", "old_path": "src/impl/RetryStrategy.ts", "new_path": "src/impl/retryStrategy.ts", "diff": "@@ -3,7 +3,7 @@ import {getRetryDelay} from '../errors'\n/**\n* Represents a strategy for calculating retry delays.\n*/\n-export default interface RetryStrategy {\n+export interface RetryStrategy {\nnextDelay(error?: Error): number\nsuccess(): void\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -56,9 +56,6 @@ describe('NodeHttpTransport', () => {\nurl: 'http://test:9999',\n})\nexpect(transport.requestApi).to.equal(http.request)\n- expect(transport.retryJitter).to.equal(\n- DEFAULT_ConnectionOptions.retryJitter\n- )\n})\nit('creates the transport from https url', () => {\nconst transport: any = new NodeHttpTransport({\n" }, { "change_type": "RENAME", "old_path": "test/unit/impl/RetryStrategy.test.ts", "new_path": "test/unit/impl/retryStrategy.test.ts", "diff": "import {expect} from 'chai'\n-import {RetryStrategyImpl} from '../../../src/impl/RetryStrategy'\n+import {\n+ RetryStrategyImpl,\n+ DEFAULT_BuiltinStrategyConfig,\n+} from '../../../src/impl/retryStrategy'\nimport {HttpError} from '../../../src'\ndescribe('RetryStrategyImpl', () => {\n+ it('has constructor that uses defaults on no DATA', () => {\n+ expect(() => new RetryStrategyImpl()).to.not.throw()\n+ expect(() => new RetryStrategyImpl({})).to.not.throw()\n+ expect(new RetryStrategyImpl())\n+ .property('options')\n+ .is.deep.equal(DEFAULT_BuiltinStrategyConfig)\n+ expect(new RetryStrategyImpl({}))\n+ .property('options')\n+ .is.deep.equal(DEFAULT_BuiltinStrategyConfig)\n+ })\nit('generates exponential data from min to max for unknown delays', () => {\nconst subject = new RetryStrategyImpl({\nminDelay: 100,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(retry): use retry strategy in node transport
305,159
17.12.2019 15:01:17
-3,600
ed83872f85b8893e54feb6868a07fde26e464a64
feat: simplify query demo
[ { "change_type": "MODIFY", "old_path": "examples/query.ts", "new_path": "examples/query.ts", "diff": "// Shows how to use InfluxDB query API. //\n//////////////////////////////////////////\n-import {InfluxDB} from '../src'\n+import {InfluxDB, FluxTableMetaData} from '../src'\nimport {url, token, org} from './env'\n-import {FluxTableMetaData} from '../src/query'\nconst queryApi = new InfluxDB({url, token}).getQueryApi(org)\nconst fluxQuery =\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: simplify query demo
305,159
17.12.2019 15:53:47
-3,600
017a6333fb0c035cd4b4dc84771535a4800d0b59
feat: add RetryBuffer tests
[ { "change_type": "MODIFY", "old_path": "src/impl/RetryBuffer.ts", "new_path": "src/impl/RetryBuffer.ts", "diff": "import Logger from './Logger'\n-// TODO create retry options\n-/* minimum time to schedule retry */\n-const MIN_RETRY_DELAY = 100\n/* interval between successful retries */\nconst RETRY_INTERVAL = 1\n@@ -15,7 +12,7 @@ interface RetryItem {\n/**\n* Retries lines up to a limit of max buffer size.\n*/\n-export class RetryBuffer {\n+export default class RetryBuffer {\nfirst?: RetryItem\nlast?: RetryItem\nsize = 0\n@@ -25,7 +22,6 @@ export class RetryBuffer {\nconstructor(\nprivate maxLines: number,\n- private jitterDelay: number,\nprivate retryLines: (\nlines: string[],\nretryCountdown: number\n@@ -37,7 +33,7 @@ export class RetryBuffer {\nif (!lines.length) return\nconst retryTime = Date.now() + delay\nif (retryTime > this.nextRetryTime) this.nextRetryTime = retryTime\n- // ensure at most maxLines ar in the buffer\n+ // ensure at most maxLines are in the Buffer\nwhile (this.first && this.size + lines.length > this.maxLines) {\nconst newFirst = this.first.next\nthis.size -= this.first.lines.length\n@@ -53,10 +49,9 @@ export class RetryBuffer {\n} else {\nthis.first = toAdd\nthis.last = toAdd\n- if (!this._timeoutHandle) {\nthis.scheduleRetry(delay)\n}\n- }\n+ this.size += lines.length\n}\nremoveLines(): RetryItem | undefined {\n@@ -86,7 +81,7 @@ export class RetryBuffer {\n} else {\nthis._timeoutHandle = undefined\n}\n- }, Math.max(MIN_RETRY_DELAY, delay + Math.random() * this.jitterDelay))\n+ }, delay)\n}\nasync flush(): Promise<void> {\n@@ -107,5 +102,6 @@ export class RetryBuffer {\nclearTimeout(this._timeoutHandle)\nthis._timeoutHandle = undefined\n}\n+ this.closed = true\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/impl/RetryBuffer.test.ts", "diff": "+import {expect} from 'chai'\n+import RetryBuffer from '../../../src/impl/RetryBuffer'\n+\n+describe('RetryBuffer', () => {\n+ it('stores lines for future retry', async () => {\n+ const input = [] as Array<[string[], number]>\n+ const output = [] as Array<[string[], number]>\n+ const subject = new RetryBuffer(100, (lines, countdown) => {\n+ output.push([lines, countdown])\n+ return Promise.resolve()\n+ })\n+ for (let i = 0; i < 10; i++) {\n+ input.push([['a' + i], i])\n+ subject.addLines(['a' + i], i, 2)\n+ }\n+ await new Promise<void>((resolve, _reject) =>\n+ setTimeout(() => resolve(), 10)\n+ )\n+ expect(output).length.is.greaterThan(0)\n+ subject.addLines([], 1, 1) // shall be ignored\n+ subject.close()\n+ subject.addLines(['x'], 1, 1) // shall be ignored\n+ await subject.flush()\n+ expect(input).deep.equals(output)\n+ })\n+ it('ignores lines on heave load', async () => {\n+ const input = [] as Array<[string[], number]>\n+ const output = [] as Array<[string[], number]>\n+ const subject = new RetryBuffer(5, (lines, countdown) => {\n+ output.push([lines, countdown])\n+ return Promise.resolve()\n+ })\n+ for (let i = 0; i < 10; i++) {\n+ if (i >= 5) input.push([['a' + i], i])\n+ subject.addLines(['a' + i], i, 100)\n+ }\n+ await new Promise<void>((resolve, _reject) =>\n+ setTimeout(() => resolve(), 10)\n+ )\n+ await subject.flush()\n+ subject.close()\n+ expect(input).deep.equals(output)\n+ })\n+ it('retries after flush', async () => {\n+ const output = [] as Array<[string[], number]>\n+ const subject = new RetryBuffer(5, (lines, countdown) => {\n+ output.push([lines, countdown])\n+ return Promise.resolve()\n+ })\n+ subject.addLines(['a'], 1, 20)\n+ await subject.flush()\n+ await new Promise<void>(\n+ (resolve, _reject) => setTimeout(() => resolve(), 21) // let scheduled retry finish\n+ )\n+ subject.close()\n+ expect([[['a'], 1]]).deep.equals(output)\n+ })\n+ it('retries also on error', async () => {\n+ const input = [] as Array<[string[], number]>\n+ const output = [] as Array<[string[], number]>\n+ let succeed = false\n+ const subject = new RetryBuffer(100, (lines, countdown) => {\n+ output.push([lines, countdown])\n+ return succeed ? Promise.resolve() : Promise.reject(new Error())\n+ })\n+ for (let i = 0; i < 10; i++) {\n+ input.push([['a' + i], i])\n+ subject.addLines(['a' + i], i, 2)\n+ }\n+ await new Promise<void>((resolve, _reject) =>\n+ setTimeout(() => resolve(), 10)\n+ )\n+ expect(output).length.is.greaterThan(0)\n+ subject.addLines([], 1, 1) // shall be ignored\n+ subject.close()\n+ subject.addLines(['x'], 1, 1) // shall be ignored\n+ succeed = true\n+ await subject.flush()\n+ expect(input).deep.equals(output)\n+ })\n+})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add RetryBuffer tests
305,159
18.12.2019 06:49:18
-3,600
bd9f9a1d404cafb99bed9d6e572f4bfd58bd1bdf
feat: use RetryBuffer in WriteApiImpl
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -9,10 +9,12 @@ import {\n} from '../options'\nimport {Transport, SendOptions} from '../transport'\nimport Logger from './Logger'\n-import {getRetryDelay, HttpError} from '../errors'\n+import {HttpError} from '../errors'\nimport Point from '../Point'\nimport {escape} from '../util/escape'\nimport {currentTime} from '../util/currentTime'\n+import {RetryStrategy, RetryStrategyImpl} from './retryStrategy'\n+import RetryBuffer from './RetryBuffer'\nclass WriteBuffer {\nlength = 0\n@@ -54,7 +56,7 @@ class WriteBuffer {\n}\nexport default class WriteApiImpl implements WriteApi, PointSettings {\n- private buffer: WriteBuffer\n+ private writeBuffer: WriteBuffer\nprivate closed = false\nprivate httpPath: string\nprivate writeOptions: WriteOptions\n@@ -65,10 +67,12 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n'content-type': 'text/plain; charset=utf-8',\n},\n}\n- private retryJitter: number\nprivate _timeoutHandle: any = undefined\nprivate currentTime: () => string\n+ retryBuffer: RetryBuffer\n+ retryStrategy: RetryStrategy\n+\nconstructor(\nprivate transport: Transport,\norg: string,\n@@ -85,7 +89,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\nthis.currentTime = currentTime[precision]\n- this.retryJitter =\n+ const retryJitter =\nclientOptions.retryJitter !== undefined\n? clientOptions.retryJitter\n: (DEFAULT_ConnectionOptions.retryJitter as number)\n@@ -98,7 +102,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nthis._timeoutHandle = setTimeout(\n() =>\nthis.sendBatch(\n- this.buffer.reset(),\n+ this.writeBuffer.reset(),\nthis.writeOptions.maxRetries\n).catch(_e => {\n// an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n@@ -108,7 +112,8 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\n}\n}\n- this.buffer = new WriteBuffer(\n+ // write buffer\n+ this.writeBuffer = new WriteBuffer(\nthis.writeOptions.batchSize,\nlines => {\nthis._clearFlushTimeout()\n@@ -117,6 +122,12 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nscheduleNextSend\n)\nthis.sendBatch = this.sendBatch.bind(this)\n+ // retry buffer\n+ this.retryStrategy = new RetryStrategyImpl({retryJitter})\n+ this.retryBuffer = new RetryBuffer(\n+ this.writeOptions.retryBufferLines,\n+ this.sendBatch\n+ )\n}\nsendBatch(lines: string[], retryCountdown: number): Promise<void> {\n@@ -136,10 +147,10 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n`Write to influx DB failed (remaining attempts: ${retryCountdown}).`,\nerror\n)\n- self._retry(\n+ self.retryBuffer.addLines(\nlines,\n- retryCountdown - 1,\n- getRetryDelay(error, self.retryJitter)\n+ retryCountdown,\n+ self.retryStrategy.nextDelay(error)\n)\nreject(error)\n} else {\n@@ -164,45 +175,29 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\n}\n- private _retry(\n- lines: string[],\n- remainingRetries: number,\n- retryDelay: number\n- ): void {\n- /* istanbul ignore else manually reviewed, hard to reproduce */\n- if (!this.closed) {\n- // TODO queue, monitor and limit retries, cancel them on close\n- setTimeout(() => {\n- this.sendBatch(lines, remainingRetries).catch(() => {\n- // an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n- })\n- }, retryDelay)\n- }\n- }\n-\nwriteRecord(record: string): void {\n- this.buffer.add(record)\n+ this.writeBuffer.add(record)\n}\nwriteRecords(records: ArrayLike<string>): void {\nfor (let i = 0; i < records.length; i++) {\n- this.buffer.add(records[i])\n+ this.writeBuffer.add(records[i])\n}\n}\nwritePoint(point: Point): void {\nconst line = point.toLineProtocol(this)\nconsole.log(line)\n- if (line) this.buffer.add(line)\n+ if (line) this.writeBuffer.add(line)\n}\nwritePoints(points: ArrayLike<Point>): void {\nfor (let i = 0; i < points.length; i++) {\nthis.writePoint(points[i])\n}\n}\n- flush(): Promise<void> {\n- return this.buffer.flush()\n+ async flush(): Promise<void> {\n+ return this.writeBuffer.flush().then(() => this.retryBuffer.flush())\n}\n- close(): Promise<void> {\n- const retVal = this.sendBatch(this.buffer.reset(), 0)\n+ async close(): Promise<void> {\n+ const retVal = this.writeBuffer.flush().then(() => this.retryBuffer.close())\nthis.closed = true\nreturn retVal\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -100,8 +100,12 @@ describe('WriteApiImpl', () => {\n// wait for http calls to finish\nawait new Promise(resolve => setTimeout(resolve, 10))\nawait subject.close().then(() => {\n- expect(logs.error).to.length(3)\n- expect(logs.warn).to.length(3 * 2)\n+ expect(logs.error).to.length(0)\n+ expect(logs.warn).length.is.greaterThan(3) // 3 warning about write fail, one about remaining items\n+ expect(logs.warn[3][0]).includes(\n+ '3',\n+ 'Warning message informs about count of missing lines'\n+ )\n})\n})\nit('does not retry write when configured to do so', async () => {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: use RetryBuffer in WriteApiImpl
305,159
18.12.2019 07:58:12
-3,600
82e76911dcb2c20ea8c3292d0a06e079d0a7c669
feat: introduce RetryDelayStrategy
[ { "change_type": "MODIFY", "old_path": "src/errors.ts", "new_path": "src/errors.ts", "diff": "+/**\n+ * Strategy for calculating retry delays.\n+ */\n+export interface RetryDelayStrategy {\n+ /**\n+ * Returns delay for a next retry\n+ * @param error reason for retrying\n+ * @return milliseconds\n+ */\n+ nextDelay(error?: Error): number\n+ /** Implementation should reset its state, this is mandatory to call upon success. */\n+ success(): void\n+}\n+\n+/**\n+ * Interface for errors to inform that an associated operation can be retried.\n+ */\nexport interface RetriableDecision {\n+ /**\n+ * Informs whether this can be retried.\n+ */\ncanRetry(): boolean\n/**\n* Get the delay in milliseconds to retry the action.\n" }, { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -8,10 +8,11 @@ import {\nResponseAbortedError,\ncanRetryHttpCall,\nHttpError,\n+ RetryDelayStrategy,\n} from '../errors'\nimport {CommunicationObserver, Transport, SendOptions} from '../transport'\nimport Cancellable from '../util/Cancellable'\n-import {RetryStrategy, RetryStrategyImpl} from './retryStrategy'\n+import {RetryStrategyImpl} from './retryStrategy'\nclass CancellableImpl implements Cancellable {\nprivate cancelled = false\n@@ -41,7 +42,7 @@ export class NodeHttpTransport implements Transport {\noptions: http.RequestOptions,\ncallback: (res: http.IncomingMessage) => void\n) => http.ClientRequest\n- retryStrategy: RetryStrategy\n+ retryStrategy: RetryDelayStrategy\n/**\n* Creates a node transport using for the client options supplied.\n* @param connectionOptions client options\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -9,11 +9,11 @@ import {\n} from '../options'\nimport {Transport, SendOptions} from '../transport'\nimport Logger from './Logger'\n-import {HttpError} from '../errors'\n+import {HttpError, RetryDelayStrategy} from '../errors'\nimport Point from '../Point'\nimport {escape} from '../util/escape'\nimport {currentTime} from '../util/currentTime'\n-import {RetryStrategy, RetryStrategyImpl} from './retryStrategy'\n+import {RetryStrategyImpl} from './retryStrategy'\nimport RetryBuffer from './RetryBuffer'\nclass WriteBuffer {\n@@ -71,7 +71,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nprivate currentTime: () => string\nretryBuffer: RetryBuffer\n- retryStrategy: RetryStrategy\n+ retryStrategy: RetryDelayStrategy\nconstructor(\nprivate transport: Transport,\n@@ -159,6 +159,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\n},\ncomplete(): void {\n+ self.retryStrategy.success()\nresolve()\n},\n})\n" }, { "change_type": "MODIFY", "old_path": "src/impl/retryStrategy.ts", "new_path": "src/impl/retryStrategy.ts", "diff": "-import {getRetryDelay} from '../errors'\n+import {getRetryDelay, RetryDelayStrategy} from '../errors'\n-/**\n- * Represents a strategy for calculating retry delays.\n- */\n-export interface RetryStrategy {\n- nextDelay(error?: Error): number\n- success(): void\n-}\n-\n-export interface BuiltinStrategyOptions {\n+export interface BuiltinRetryStrategyOptions {\nretryJitter: number\nminDelay: number\nmaxDelay: number\n}\n-export const DEFAULT_BuiltinStrategyConfig: BuiltinStrategyOptions = {\n+export const DEFAULT_BuiltinStrategyConfig: BuiltinRetryStrategyOptions = {\nretryJitter: 500,\nminDelay: 1000,\nmaxDelay: 15000,\n}\n/**\n- * Applies a variant of exponential backoff with initial max delay with a random\n- * jitter delay and repects alsi retry after settings of supplied errors.\n+ * Applies a variant of exponential backoff with initial and max delay and a random\n+ * jitter delay. It also respects `retry delay` when specified together with an error.\n*/\n-export class RetryStrategyImpl implements RetryStrategy {\n- options: BuiltinStrategyOptions\n+export class RetryStrategyImpl implements RetryDelayStrategy {\n+ options: BuiltinRetryStrategyOptions\ncurrentDelay: number | undefined\n- constructor(options?: Partial<BuiltinStrategyOptions>) {\n+ constructor(options?: Partial<BuiltinRetryStrategyOptions>) {\nthis.options = {...DEFAULT_BuiltinStrategyConfig, ...options}\nthis.success()\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: introduce RetryDelayStrategy
305,159
18.12.2019 11:49:25
-3,600
9e0c39b9369354c3686898384399f83869cb74e5
fix(ligging): do not print error when missing
[ { "change_type": "MODIFY", "old_path": "src/impl/Logger.ts", "new_path": "src/impl/Logger.ts", "diff": "* Logging interface.\n*/\nexport interface Logger {\n- error(message: string, err: any): void\n- warn(message: string, err: any): void\n+ error(message: string, err?: any): void\n+ warn(message: string, err?: any): void\n}\n/**\n@@ -11,10 +11,10 @@ export interface Logger {\n*/\nexport const consoleLogger: Logger = Object.freeze({\nerror(message, error) {\n- console.error('ERROR: ' + message, error)\n+ console.error('ERROR: ' + message, error ? error : '')\n},\nwarn(message, error) {\n- console.warn('WARN: ' + message, error)\n+ console.warn('WARN: ' + message, error ? error : '')\n},\n})\nlet provider: Logger = consoleLogger\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/Logger.test.ts", "new_path": "test/unit/impl/Logger.test.ts", "diff": "@@ -2,8 +2,8 @@ import {expect} from 'chai'\nimport Logger, {setLogger, consoleLogger} from '../../../src/impl/Logger'\ndescribe('Logger', () => {\n- const testSet = {message: ' hey', error: 'you'}\n- it(\"uses custom logger's error\", () => {\n+ ;[{message: ' hey', error: 'you'}, {message: ' hey'}].forEach(data => {\n+ it(`uses custom logger's error (${Object.keys(data).length})`, () => {\nlet args: Array<any> | undefined\nsetLogger({\nerror(message, error): void {\n@@ -14,10 +14,10 @@ describe('Logger', () => {\nconsoleLogger.warn(message, error)\n},\n})\n- Logger.error.call(Logger, testSet.message, testSet.error)\n- expect(args).to.be.deep.equal([testSet.message, testSet.error])\n+ Logger.error.call(Logger, data.message, data.error)\n+ expect(args).to.be.deep.equal([data.message, data.error])\n})\n- it(\"uses custom logger's warn\", () => {\n+ it(`uses custom logger's warn (${Object.keys(data).length})`, () => {\nlet args: Array<any> | undefined\nsetLogger({\nerror(message, error): void {\n@@ -29,7 +29,8 @@ describe('Logger', () => {\n},\n})\n- Logger.warn.call(Logger, testSet.message, testSet.error)\n- expect(args).to.be.deep.equal([testSet.message, testSet.error])\n+ Logger.warn.call(Logger, data.message, data.error)\n+ expect(args).to.be.deep.equal([data.message, data.error])\n+ })\n})\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
fix(ligging): do not print error when missing
305,159
18.12.2019 16:23:40
-3,600
49e0b262409085912517ec59b79de56d6ed65902
feat(write): introduce write/retry options
[ { "change_type": "MODIFY", "old_path": "src/InfluxDB.ts", "new_path": "src/InfluxDB.ts", "diff": "@@ -84,7 +84,7 @@ export default class InfluxDB {\norg,\nbucket,\nprecision,\n- this._options\n+ this._options.writeOptions\n)\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/RetryBuffer.ts", "new_path": "src/impl/RetryBuffer.ts", "diff": "@@ -93,7 +93,7 @@ export default class RetryBuffer {\nclose(): void {\nif (this.size > 0) {\n- Logger.warn(\n+ Logger.error(\n`Closing retry buffer, ${this.size} items were not written to InfluxDB!`,\nnull\n)\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -2,8 +2,6 @@ import WriteApi from '../WriteApi'\nimport {\nWritePrecision,\nDEFAULT_WriteOptions,\n- ClientOptions,\n- DEFAULT_ConnectionOptions,\nPointSettings,\nWriteOptions,\n} from '../options'\n@@ -78,22 +76,17 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\norg: string,\nbucket: string,\nprecision: WritePrecision,\n- clientOptions: ClientOptions\n+ writeOptions?: Partial<WriteOptions>\n) {\nthis.httpPath = `/api/v2/write?org=${encodeURIComponent(\norg\n)}&bucket=${encodeURIComponent(bucket)}&precision=${precision}`\nthis.writeOptions = {\n...DEFAULT_WriteOptions,\n- ...clientOptions.writeOptions,\n+ ...writeOptions,\n}\nthis.currentTime = currentTime[precision]\n- const retryJitter =\n- clientOptions.retryJitter !== undefined\n- ? clientOptions.retryJitter\n- : (DEFAULT_ConnectionOptions.retryJitter as number)\n-\nconst scheduleNextSend = (): void => {\nif (this.writeOptions.flushInterval > 0) {\nthis._clearFlushTimeout()\n@@ -103,7 +96,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n() =>\nthis.sendBatch(\nthis.writeBuffer.reset(),\n- this.writeOptions.maxRetries\n+ this.writeOptions.maxRetries + 1\n).catch(_e => {\n// an error is logged in case of failure, avoid UnhandledPromiseRejectionWarning\n}),\n@@ -117,20 +110,20 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nthis.writeOptions.batchSize,\nlines => {\nthis._clearFlushTimeout()\n- return this.sendBatch(lines, this.writeOptions.maxRetries)\n+ return this.sendBatch(lines, this.writeOptions.maxRetries + 1)\n},\nscheduleNextSend\n)\nthis.sendBatch = this.sendBatch.bind(this)\n// retry buffer\n- this.retryStrategy = new RetryStrategyImpl({retryJitter})\n+ this.retryStrategy = new RetryStrategyImpl(this.writeOptions)\nthis.retryBuffer = new RetryBuffer(\n- this.writeOptions.retryBufferLines,\n+ this.writeOptions.maxBufferLines,\nthis.sendBatch\n)\n}\n- sendBatch(lines: string[], retryCountdown: number): Promise<void> {\n+ sendBatch(lines: string[], attempts: number): Promise<void> {\n// eslint-disable-next-line @typescript-eslint/no-this-alias\nconst self: WriteApiImpl = this\nif (!this.closed && lines.length > 0) {\n@@ -139,17 +132,18 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nerror(error: Error): void {\nif (\n!self.closed &&\n- retryCountdown > 0 &&\n+ attempts > 1 &&\n(!(error instanceof HttpError) ||\n(error as HttpError).statusCode >= 429)\n) {\nLogger.warn(\n- `Write to influx DB failed (remaining attempts: ${retryCountdown}).`,\n+ `Write to influx DB failed (remaining attempts: ${attempts -\n+ 1}).`,\nerror\n)\nself.retryBuffer.addLines(\nlines,\n- retryCountdown,\n+ attempts - 1,\nself.retryStrategy.nextDelay(error)\n)\nreject(error)\n@@ -198,8 +192,10 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nreturn this.writeBuffer.flush().then(() => this.retryBuffer.flush())\n}\nasync close(): Promise<void> {\n- const retVal = this.writeBuffer.flush().then(() => this.retryBuffer.close())\n+ const retVal = this.writeBuffer.flush().finally(() => {\n+ this.retryBuffer.close()\nthis.closed = true\n+ })\nreturn retVal\n}\ndispose(): void {\n" }, { "change_type": "MODIFY", "old_path": "src/impl/retryStrategy.ts", "new_path": "src/impl/retryStrategy.ts", "diff": "import {getRetryDelay, RetryDelayStrategy} from '../errors'\n-\n-export interface BuiltinRetryStrategyOptions {\n- retryJitter: number\n- minDelay: number\n- maxDelay: number\n-}\n-\n-export const DEFAULT_BuiltinStrategyConfig: BuiltinRetryStrategyOptions = {\n- retryJitter: 500,\n- minDelay: 1000,\n- maxDelay: 15000,\n-}\n+import {\n+ RetryDelayStrategyOptions,\n+ DEFAULT_RetryDelayStrategyOptions,\n+} from '../options'\n/**\n* Applies a variant of exponential backoff with initial and max delay and a random\n* jitter delay. It also respects `retry delay` when specified together with an error.\n*/\nexport class RetryStrategyImpl implements RetryDelayStrategy {\n- options: BuiltinRetryStrategyOptions\n+ options: RetryDelayStrategyOptions\ncurrentDelay: number | undefined\n- constructor(options?: Partial<BuiltinRetryStrategyOptions>) {\n- this.options = {...DEFAULT_BuiltinStrategyConfig, ...options}\n+ constructor(options?: Partial<RetryDelayStrategyOptions>) {\n+ this.options = {...DEFAULT_RetryDelayStrategyOptions, ...options}\nthis.success()\n}\n@@ -30,18 +22,18 @@ export class RetryStrategyImpl implements RetryDelayStrategy {\nif (delay && delay > 0) {\nreturn Math.min(\ndelay + Math.round(Math.random() * this.options.retryJitter),\n- this.options.maxDelay\n+ this.options.maxRetryDelay\n)\n} else {\nif (this.currentDelay) {\nthis.currentDelay = Math.min(\nMath.max(this.currentDelay * 2, 1) +\nMath.round(Math.random() * this.options.retryJitter),\n- this.options.maxDelay\n+ this.options.maxRetryDelay\n)\n} else {\nthis.currentDelay =\n- this.options.minDelay +\n+ this.options.minRetryDelay +\nMath.round(Math.random() * this.options.retryJitter)\n}\nreturn this.currentDelay\n" }, { "change_type": "MODIFY", "old_path": "src/options.ts", "new_path": "src/options.ts", "diff": "@@ -21,24 +21,44 @@ export const DEFAULT_ConnectionOptions: Partial<ConnectionOptions> = {\nretryJitter: 1000,\n}\n+export interface RetryDelayStrategyOptions {\n+ /** include random milliseconds when retrying HTTP calls */\n+ retryJitter: number\n+ /** minimum delay when retrying write */\n+ minRetryDelay: number\n+ /** maximum delay when retrying write */\n+ maxRetryDelay: number\n+}\n+\n+export interface WriteRetryOptions extends RetryDelayStrategyOptions {\n+ /** max number of retries when write fails */\n+ maxRetries: number\n+ /** the maximum size of retry-buffer (in lines) */\n+ maxBufferLines: number\n+}\n+\n/**\n* Options used by [[WriteApi]]\n*/\n-export interface WriteOptions {\n+export interface WriteOptions extends WriteRetryOptions {\n/** max number of records to send in a batch */\nbatchSize: number\n/** delay between data flushes in milliseconds, at most `batch size` records are sent during flush */\nflushInterval: number\n- /** max number of retries when write fails */\n- maxRetries: number\n- /** the maximum size of retry-buffer (in lines) */\n- retryBufferLines: number\n}\n+\n+export const DEFAULT_RetryDelayStrategyOptions = Object.freeze({\n+ retryJitter: 200,\n+ minRetryDelay: 1000,\n+ maxRetryDelay: 15000,\n+})\n+\nexport const DEFAULT_WriteOptions: WriteOptions = Object.freeze({\nbatchSize: 1000,\nflushInterval: 60000,\nmaxRetries: 2,\n- retryBufferLines: 32_000,\n+ maxBufferLines: 32_000,\n+ ...DEFAULT_RetryDelayStrategyOptions,\n})\nexport interface ClientOptions extends ConnectionOptions {\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -35,18 +35,14 @@ describe('WriteApiImpl', () => {\nlet subject: WriteApiImpl\nlet logs: CollectedLogs\nbeforeEach(() => {\n- subject = new WriteApiImpl(\n- transport,\n- ORG,\n- BUCKET,\n- PRECISION,\n- clientOptions\n- )\n+ subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n+ retryJitter: 0,\n+ })\n// logs = collectLogging.decorate()\nlogs = collectLogging.replace()\n})\nafterEach(async () => {\n- subject.close()\n+ await subject.close()\ncollectLogging.after()\n})\nit('can be closed and flushed without any data', async () => {\n@@ -60,7 +56,7 @@ describe('WriteApiImpl', () => {\n.close()\n.then(() => expect.fail('failure expected'))\n.catch(e => {\n- expect(logs.error).to.length(1)\n+ expect(logs.error).length.greaterThan(0)\nexpect(e).to.be.ok\n})\n})\n@@ -81,8 +77,8 @@ describe('WriteApiImpl', () => {\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\nsubject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n- ...clientOptions,\n- writeOptions,\n+ retryJitter: 0,\n+ ...writeOptions,\n})\n}\nbeforeEach(() => {\n@@ -90,19 +86,23 @@ describe('WriteApiImpl', () => {\nlogs = collectLogging.replace()\n})\nafterEach(async () => {\n- subject.close()\n+ await subject.close()\ncollectLogging.after()\n})\nit('flushes the data in specified batchSize', async () => {\n- useSubject({flushInterval: 0, batchSize: 1, maxRetries: 2})\n+ useSubject({\n+ flushInterval: 0,\n+ batchSize: 1,\n+ maxRetries: 2,\n+ })\nsubject.writeRecord('test value=1')\nsubject.writeRecords(['test value=2', 'test value=3'])\n// wait for http calls to finish\nawait new Promise(resolve => setTimeout(resolve, 10))\nawait subject.close().then(() => {\n- expect(logs.error).to.length(0)\n- expect(logs.warn).length.is.greaterThan(3) // 3 warning about write fail, one about remaining items\n- expect(logs.warn[3][0]).includes(\n+ expect(logs.error).to.length(1)\n+ expect(logs.warn).length(3) // 3 warnings about write failure\n+ expect(logs.error[0][0]).includes(\n'3',\n'Warning message informs about count of missing lines'\n)\n@@ -113,7 +113,7 @@ describe('WriteApiImpl', () => {\nsubject.writeRecord('test value=1')\nawait subject.close().then(() => {\nexpect(logs.error).to.length(1)\n- expect(logs.warn).to.length(0)\n+ expect(logs.warn).is.deep.equal([])\n})\n})\nit('uses the pre-configured batchSize', async () => {\n@@ -130,8 +130,8 @@ describe('WriteApiImpl', () => {\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\nsubject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n- ...clientOptions,\n- writeOptions,\n+ retryJitter: 0,\n+ ...writeOptions,\n})\n}\nbeforeEach(() => {\n@@ -139,7 +139,7 @@ describe('WriteApiImpl', () => {\nlogs = collectLogging.replace()\n})\nafterEach(async () => {\n- subject.close()\n+ await subject.close()\ncollectLogging.after()\n})\nit('flushes the records automatically', async () => {\n@@ -161,8 +161,9 @@ describe('WriteApiImpl', () => {\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\nsubject = new WriteApiImpl(transport, ORG, BUCKET, WritePrecision.ns, {\n- ...clientOptions,\n- writeOptions,\n+ retryJitter: 0,\n+\n+ ...writeOptions,\n}).useDefaultTags({xtra: '1'})\n}\nbeforeEach(() => {\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/retryStrategy.test.ts", "new_path": "test/unit/impl/retryStrategy.test.ts", "diff": "import {expect} from 'chai'\n-import {\n- RetryStrategyImpl,\n- DEFAULT_BuiltinStrategyConfig,\n-} from '../../../src/impl/retryStrategy'\n-import {HttpError} from '../../../src'\n+import {RetryStrategyImpl} from '../../../src/impl/retryStrategy'\n+import {HttpError, DEFAULT_RetryDelayStrategyOptions} from '../../../src'\ndescribe('RetryStrategyImpl', () => {\nit('has constructor that uses defaults on no DATA', () => {\n@@ -11,15 +8,15 @@ describe('RetryStrategyImpl', () => {\nexpect(() => new RetryStrategyImpl({})).to.not.throw()\nexpect(new RetryStrategyImpl())\n.property('options')\n- .is.deep.equal(DEFAULT_BuiltinStrategyConfig)\n+ .is.deep.equal(DEFAULT_RetryDelayStrategyOptions)\nexpect(new RetryStrategyImpl({}))\n.property('options')\n- .is.deep.equal(DEFAULT_BuiltinStrategyConfig)\n+ .is.deep.equal(DEFAULT_RetryDelayStrategyOptions)\n})\nit('generates exponential data from min to max for unknown delays', () => {\nconst subject = new RetryStrategyImpl({\n- minDelay: 100,\n- maxDelay: 1000,\n+ minRetryDelay: 100,\n+ maxRetryDelay: 1000,\nretryJitter: 0,\n})\nconst values = [1, 2, 3, 4, 5, 6].reduce((acc, _val) => {\n@@ -32,8 +29,8 @@ describe('RetryStrategyImpl', () => {\n})\nit('generates the delays according to errors', () => {\nconst subject = new RetryStrategyImpl({\n- minDelay: 100,\n- maxDelay: 1000,\n+ minRetryDelay: 100,\n+ maxRetryDelay: 1000,\nretryJitter: 0,\n})\nconst values = [1, 2, 3, 4, 5, 6].reduce((acc, val) => {\n@@ -44,8 +41,8 @@ describe('RetryStrategyImpl', () => {\n})\nit('generates jittered delays according to error delay', () => {\nconst subject = new RetryStrategyImpl({\n- minDelay: 100,\n- maxDelay: 1000,\n+ minRetryDelay: 100,\n+ maxRetryDelay: 1000,\nretryJitter: 10,\n})\nconst values = [1, 2, 3, 4, 5, 6].reduce((acc, val) => {\n@@ -60,8 +57,8 @@ describe('RetryStrategyImpl', () => {\n})\nit('generates default jittered delays', () => {\nconst subject = new RetryStrategyImpl({\n- minDelay: 100,\n- maxDelay: 1000,\n+ minRetryDelay: 100,\n+ maxRetryDelay: 1000,\nretryJitter: 10,\n})\nconst values = [1, 2, 3, 4, 5, 6].reduce((acc, val) => {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(write): introduce write/retry options
305,159
18.12.2019 16:27:34
-3,600
a495fd093e775a22d95dd135d67ce3ea3fe7788a
chore: do not instantiate retry strategy directly
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -11,7 +11,7 @@ import {HttpError, RetryDelayStrategy} from '../errors'\nimport Point from '../Point'\nimport {escape} from '../util/escape'\nimport {currentTime} from '../util/currentTime'\n-import {RetryStrategyImpl} from './retryStrategy'\n+import {createRetryStrategy} from './retryStrategy'\nimport RetryBuffer from './RetryBuffer'\nclass WriteBuffer {\n@@ -116,7 +116,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n)\nthis.sendBatch = this.sendBatch.bind(this)\n// retry buffer\n- this.retryStrategy = new RetryStrategyImpl(this.writeOptions)\n+ this.retryStrategy = createRetryStrategy(this.writeOptions)\nthis.retryBuffer = new RetryBuffer(\nthis.writeOptions.maxBufferLines,\nthis.sendBatch\n" }, { "change_type": "MODIFY", "old_path": "src/impl/retryStrategy.ts", "new_path": "src/impl/retryStrategy.ts", "diff": "@@ -4,6 +4,15 @@ import {\nDEFAULT_RetryDelayStrategyOptions,\n} from '../options'\n+/**\n+ * Return a new instance of [[RetryStrategyImpl]]\n+ */\n+export function createRetryStrategy(\n+ options?: Partial<RetryDelayStrategyOptions>\n+) {\n+ return new RetryStrategyImpl(options)\n+}\n+\n/**\n* Applies a variant of exponential backoff with initial and max delay and a random\n* jitter delay. It also respects `retry delay` when specified together with an error.\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: do not instantiate retry strategy directly
305,159
18.12.2019 17:33:32
-3,600
ae607a8a1cd114d00e4b851ad719825a78502769
feat: log error message when reducing buffer size, reduce buffer to 70% when required
[ { "change_type": "MODIFY", "old_path": "src/impl/RetryBuffer.ts", "new_path": "src/impl/RetryBuffer.ts", "diff": "@@ -35,11 +35,20 @@ export default class RetryBuffer {\nif (retryTime > this.nextRetryTime) this.nextRetryTime = retryTime\n// ensure at most maxLines are in the Buffer\nif (this.first && this.size + lines.length > this.maxLines) {\n+ const origSize = this.size\n+ const newSize = origSize * 0.7 // reduce to 70 %\ndo {\nconst newFirst = this.first.next as RetryItem\nthis.size -= this.first.lines.length\nthis.first = newFirst\n- } while (this.first && this.size + lines.length > this.maxLines)\n+ } while (this.first && this.size + lines.length > newSize)\n+ Logger.error(\n+ `RetryBuffer: ${origSize -\n+ this\n+ .size} oldest lines removed to keep buffer size under the limit of ${\n+ this.maxLines\n+ } lines`\n+ )\n}\nconst toAdd = {\nlines,\n@@ -93,17 +102,12 @@ export default class RetryBuffer {\n}\n}\n- close(): void {\n- if (this.size > 0) {\n- Logger.error(\n- `Closing retry buffer, ${this.size} items were not written to InfluxDB!`,\n- null\n- )\n- }\n+ close(): number {\nif (this._timeoutHandle) {\nclearTimeout(this._timeoutHandle)\nthis._timeoutHandle = undefined\n}\nthis.closed = true\n+ return this.size\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -11,7 +11,7 @@ import {HttpError, RetryDelayStrategy} from '../errors'\nimport Point from '../Point'\nimport {escape} from '../util/escape'\nimport {currentTime} from '../util/currentTime'\n-import {createRetryStrategy} from './retryStrategy'\n+import {createRetryDelayStrategy} from './retryStrategy'\nimport RetryBuffer from './RetryBuffer'\nclass WriteBuffer {\n@@ -116,7 +116,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n)\nthis.sendBatch = this.sendBatch.bind(this)\n// retry buffer\n- this.retryStrategy = createRetryStrategy(this.writeOptions)\n+ this.retryStrategy = createRetryDelayStrategy(this.writeOptions)\nthis.retryBuffer = new RetryBuffer(\nthis.writeOptions.maxBufferLines,\nthis.sendBatch\n@@ -193,7 +193,13 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\n}\nasync close(): Promise<void> {\nconst retVal = this.writeBuffer.flush().finally(() => {\n- this.retryBuffer.close()\n+ const remaining = this.retryBuffer.close()\n+ if (remaining) {\n+ Logger.error(\n+ `Retry buffer closed with ${remaining} items that were not written to InfluxDB!`,\n+ null\n+ )\n+ }\nthis.closed = true\n})\nreturn retVal\n" }, { "change_type": "MODIFY", "old_path": "src/impl/retryStrategy.ts", "new_path": "src/impl/retryStrategy.ts", "diff": "@@ -48,7 +48,7 @@ export class RetryStrategyImpl implements RetryDelayStrategy {\n* Creates a new instance of retry strategy\n* @param options retry options\n*/\n-export function createRetryStrategy(\n+export function createRetryDelayStrategy(\noptions?: Partial<RetryDelayStrategyOptions>\n): RetryDelayStrategy {\nreturn new RetryStrategyImpl(options)\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/RetryBuffer.test.ts", "new_path": "test/unit/impl/RetryBuffer.test.ts", "diff": "import {expect} from 'chai'\nimport RetryBuffer from '../../../src/impl/RetryBuffer'\n+import {CollectedLogs, collectLogging} from '../../util'\ndescribe('RetryBuffer', () => {\n+ let logs: CollectedLogs\n+ beforeEach(() => {\n+ logs = collectLogging.decorate()\n+ // logs = collectLogging.replace()\n+ })\n+ afterEach(async () => {\n+ collectLogging.after()\n+ })\nit('stores lines for future retry', async () => {\nconst input = [] as Array<[string[], number]>\nconst output = [] as Array<[string[], number]>\n@@ -23,7 +32,7 @@ describe('RetryBuffer', () => {\nawait subject.flush()\nexpect(input).deep.equals(output)\n})\n- it('ignores lines on heave load', async () => {\n+ it('ignores lines on heavy load', async () => {\nconst input = [] as Array<[string[], number]>\nconst output = [] as Array<[string[], number]>\nconst subject = new RetryBuffer(5, (lines, countdown) => {\n@@ -38,10 +47,11 @@ describe('RetryBuffer', () => {\nsetTimeout(() => resolve(), 10)\n)\nawait subject.flush()\n- subject.close()\n- expect(input).deep.equals(output)\n+ expect(subject.close()).equals(0)\n+ expect(logs.error).length.is.greaterThan(0) // 5 entries over limit\n+ expect(output).length.is.lessThan(6) // at most 5 items will be written\n})\n- it('retries after flush', async () => {\n+ it('retries does not fail after flush', async () => {\nconst output = [] as Array<[string[], number]>\nconst subject = new RetryBuffer(5, (lines, countdown) => {\noutput.push([lines, countdown])\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/retryStrategy.test.ts", "new_path": "test/unit/impl/retryStrategy.test.ts", "diff": "import {expect} from 'chai'\n-import {RetryStrategyImpl} from '../../../src/impl/retryStrategy'\n+import {\n+ RetryStrategyImpl,\n+ createRetryDelayStrategy,\n+} from '../../../src/impl/retryStrategy'\nimport {HttpError, DEFAULT_RetryDelayStrategyOptions} from '../../../src'\ndescribe('RetryStrategyImpl', () => {\n- it('has constructor that uses defaults on no DATA', () => {\n+ it('has constructor that uses defaults on no options', () => {\nexpect(() => new RetryStrategyImpl()).to.not.throw()\nexpect(() => new RetryStrategyImpl({})).to.not.throw()\n+ expect(() => createRetryDelayStrategy()).to.not.throw()\nexpect(new RetryStrategyImpl())\n.property('options')\n.is.deep.equal(DEFAULT_RetryDelayStrategyOptions)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: log error message when reducing buffer size, reduce buffer to 70% when required
305,159
18.12.2019 20:01:45
-3,600
16c77df68ce2c943bf898fc5ea0e0e43e68356bd
chore: minimize badges in readme
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "[![CircleCI](https://circleci.com/gh/bonitoo-io/influxdb-client-js.svg?style=svg)](https://circleci.com/gh/bonitoo-io/influxdb-client-js)\n[![codecov](https://codecov.io/gh/bonitoo-io/influxdb-client-js/branch/master/graph/badge.svg)](https://codecov.io/gh/bonitoo-io/influxdb-client-js)\n+[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![License](https://img.shields.io/github/license/bonitoo-io/influxdb-client-js.svg)](https://github.com/bonitoo-io/influxdb-client-js/blob/master/LICENSE)\n-[![GitHub issues](https://img.shields.io/github/issues-raw/bonitoo-io/influxdb-client-js.svg)](https://github.com/bonitoo-io/influxdb-client-js/issues)\n-[![GitHub pull requests](https://img.shields.io/github/issues-pr-raw/bonitoo-io/influxdb-client-js.svg)](https://github.com/bonitoo-io/influxdb-client-js/pulls)\nThis repository contains the reference javascript client for InfluxDB 2.0.\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: minimize badges in readme
305,159
19.12.2019 10:49:58
-3,600
424c62111f3c4995d2314264db39ab2ead63b328
chore: reference examples frpom main doc
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -22,9 +22,7 @@ This library is a work in progress and should not be considered production ready\n## Usage\n-- [Examples](./examples)\n- - [Write to InfluxDB](./examples/write.ts)\n- - [Query InfluxDB](./examples/query.ts)\n+See [Examples](./examples)\n## Build Requirements\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: reference examples frpom main doc
305,159
19.12.2019 11:35:16
-3,600
670ab9c4ac7ca5599e0d06b3cb426d7ad5694abd
chore: require SendOptions in WriteApiImpl
[ { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -58,7 +58,7 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nprivate closed = false\nprivate httpPath: string\nprivate writeOptions: WriteOptions\n- private sendOptions: Partial<SendOptions> = {\n+ private sendOptions: SendOptions = {\nmethod: 'POST',\nmaxRetries: 0, // we control manual retry attempts\nheaders: {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: require SendOptions in WriteApiImpl
305,159
19.12.2019 13:52:41
-3,600
b05a478421e169bc6a2f6bcd64b91deb09324a68
feat: lint also tests
[ { "change_type": "MODIFY", "old_path": ".eslintrc.json", "new_path": ".eslintrc.json", "diff": "],\n\"overrides\": [\n{\n- \"files\": [\"**/*.ts\"]\n+ \"files\": [\"src/**/*.ts\"]\n},\n{\n\"files\": [\"**/*.js\"],\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"test:watch\": \"mocha --require ts-node/register 'test/unit/**/*.test.ts' --watch-extensions ts --watch\",\n\"typecheck\": \"tsc --noEmit --pretty\",\n\"typedoc\": \"typedoc --excludePrivate --excludeNotExported --mode file --out ./reports/apidoc --target es6 --tsconfig ./tsconfig.doc.json ./src\",\n- \"lint\": \"eslint 'src/**/*.ts'\",\n+ \"lint\": \"eslint 'src/**/*.ts' 'test/**/*.ts'\",\n\"lint:ci\": \"yarn run lint --format junit --output-file reports/eslint/eslint.xml\",\n\"lint:fix\": \"eslint --fix 'src/**/*.ts'\"\n},\n" }, { "change_type": "MODIFY", "old_path": "test/unit/Point.test.ts", "new_path": "test/unit/Point.test.ts", "diff": "@@ -63,7 +63,7 @@ function createPointSettings(pointSettings: {\nif (pointSettings.convertTime) {\nreturn {\ndefaultTags: pointSettings.defaultTags,\n- convertTime: () => pointSettings.convertTime,\n+ convertTime: (): string | undefined => pointSettings.convertTime,\n}\n} else {\nreturn {\n" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "@@ -17,7 +17,7 @@ describe('errors', () => {\nnew RequestTimedOutError(),\nnew ResponseAbortedError(),\nnew HttpError(429, 'Too Many Requests', '', '2019-11-02'),\n- (() => {\n+ ((): Error => {\nconst err = new Error('Connection reset')\n;(err as any).code = 'ECONNRESET'\nreturn err\n@@ -51,7 +51,6 @@ describe('errors', () => {\nerror: new HttpError(503, 'Service Unavailable', '', '10'),\nretryAfter: 10,\n},\n- ,\n{error: new RequestTimedOutError(), retryAfter: 0},\n{error: new ResponseAbortedError(), retryAfter: 0},\n]\n@@ -82,7 +81,6 @@ describe('errors', () => {\nerror: new HttpError(503, 'Service Unavailable', '', '10'),\nretryAfter: 10,\n},\n- ,\n{error: new RequestTimedOutError(), retryAfter: 0},\n{error: new ResponseAbortedError(), retryAfter: 0},\n{error: new Error(), retryAfter: 0},\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/ChunksToLines.test.ts", "new_path": "test/unit/impl/ChunksToLines.test.ts", "diff": "@@ -13,7 +13,7 @@ interface ChunkTest {\n}\nclass CollectLinesObserver2 extends CollectLinesObserver {\n- useCancellable(cancellable: Cancellable): void {\n+ useCancellable(_cancellable: Cancellable): void {\nthis.cancellableSet = true\n}\n}\n@@ -33,6 +33,7 @@ describe('ChunksToLines', () => {\nfailed = true\nsubject.error(new Error())\n} else {\n+ // eslint-disable-next-line no-undef\nsubject.next(Buffer.from(chunk, 'utf8'))\nif (failed) {\nsubject.error(new Error())\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/Logger.test.ts", "new_path": "test/unit/impl/Logger.test.ts", "diff": "@@ -7,6 +7,7 @@ describe('Logger', () => {\nlet args: Array<any> | undefined\nsetLogger({\nerror(message, error): void {\n+ // eslint-disable-next-line prefer-rest-params\nargs = Array.from(arguments)\nconsoleLogger.error(message, error)\n},\n@@ -24,6 +25,7 @@ describe('Logger', () => {\nconsoleLogger.error(message, error)\n},\nwarn(message, error): void {\n+ // eslint-disable-next-line prefer-rest-params\nargs = Array.from(arguments)\nconsoleLogger.warn(message, error)\n},\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -140,7 +140,7 @@ describe('NodeHttpTransport', () => {\nnext(data: any) {\nnextFn(data)\n},\n- error(error: any) {\n+ error(_error: any) {\nclearTimeout(timeout)\nreject(new Error('No error expected!'))\n},\n@@ -259,7 +259,7 @@ describe('NodeHttpTransport', () => {\n.reply((_uri, _requestBody) => [\n200,\nnew Readable({\n- read() {\n+ read(): any {\nremainingChunks--\nif (!remainingChunks) {\nres.emit('aborted')\n@@ -268,7 +268,7 @@ describe('NodeHttpTransport', () => {\n},\n}),\n{\n- 'X-Whatever': (_req: any, _res: any, _body: any) => {\n+ 'X-Whatever': (_req: any, _res: any, _body: any): string => {\nres = _res\nreturn '1'\n},\n@@ -276,7 +276,7 @@ describe('NodeHttpTransport', () => {\n])\n.persist()\nawait sendTestData(transportOptions, {method: 'GET'})\n- .then(data => {\n+ .then(_data => {\nexpect.fail('not expected!')\n})\n.catch((e: any) => {\n@@ -293,7 +293,7 @@ describe('NodeHttpTransport', () => {\n.reply((_uri, _requestBody) => [\n200,\nnew Readable({\n- read() {\n+ read(): any {\nremainingChunks--\nif (!remainingChunks) {\nreq.emit('error', new Error('request failed'))\n@@ -302,7 +302,7 @@ describe('NodeHttpTransport', () => {\n},\n}),\n{\n- 'X-Whatever': (_req: any, _res: any, _body: any) => {\n+ 'X-Whatever': (_req: any, _res: any, _body: any): string => {\nreq = _req\nreturn '1'\n},\n@@ -310,7 +310,7 @@ describe('NodeHttpTransport', () => {\n])\n.persist()\nawait sendTestData(transportOptions, {method: 'GET'})\n- .then(data => {\n+ .then(_data => {\nexpect.fail('not expected!')\n})\n.catch((e: any) => {\n@@ -378,7 +378,7 @@ describe('NodeHttpTransport', () => {\n200,\n(_uri, _requestBody) =>\nnew Readable({\n- read() {\n+ read(): any {\nremainingChunks--\nif (!remainingChunks) {\ncancellable.cancel()\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -228,7 +228,7 @@ describe('WriteApiImpl', () => {\nString(Date.now()).length + 6 // nanosecond precision\n)\nexpect(lines[2]).to.be.equal('test,xtra=1 value=4 1')\n- lines.forEach(line => {})\n+ lines.forEach(_line => {})\nawait subject.flush().then(() => {\nexpect(logs.error).to.length(0)\n})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/linesToTables.test.ts", "new_path": "test/unit/impl/linesToTables.test.ts", "diff": "@@ -22,7 +22,7 @@ describe('linesToTables', () => {\n})\nit('notifies about errors', async () => {\nconst target = new CollectTablesObserver()\n- ;(target as any).useCancellable = (_x: any) => {}\n+ ;(target as any).useCancellable = (_x: any): void => {}\nconst lineObserver = toLineObserver(target)\nconst input = new ChunksToLines(lineObserver)\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/retryStrategy.test.ts", "new_path": "test/unit/impl/retryStrategy.test.ts", "diff": "@@ -65,7 +65,7 @@ describe('RetryStrategyImpl', () => {\nmaxRetryDelay: 1000,\nretryJitter: 10,\n})\n- const values = [1, 2, 3, 4, 5, 6].reduce((acc, val) => {\n+ const values = [1, 2, 3, 4, 5, 6].reduce((acc, _val) => {\nacc.push(subject.nextDelay())\nreturn acc\n}, [] as number[])\n" }, { "change_type": "MODIFY", "old_path": "test/unit/util/currentTime.test.ts", "new_path": "test/unit/util/currentTime.test.ts", "diff": "@@ -61,6 +61,7 @@ describe('currentTime', () => {\nfor (let i = 1; i < size; i++) {\n// console.log(`useProcessApi=${useProcessApi} ${data[i - 1]}`)\n+ // eslint-disable-next-line no-undef\nif (BigInt(data[i - 1]) >= BigInt(data[i])) {\nexpect.fail(\n`(${i}) ${data[i - 1]} < ${\n" }, { "change_type": "MODIFY", "old_path": "test/util.ts", "new_path": "test/util.ts", "diff": "+/* eslint-disable prefer-rest-params */\nimport {setLogger} from '../src/impl/Logger'\nlet previous: any\n@@ -40,7 +41,7 @@ export const collectLogging = {\n})\nreturn retVal\n},\n- after() {\n+ after(): void {\nif (previous) {\nsetLogger(previous)\nprevious = undefined\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: lint also tests
305,159
19.12.2019 16:16:50
-3,600
071d06a2eb27718f11fcc4c57c4053080bce8803
feat: add request method to transport
[ { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -10,7 +10,12 @@ import {\nHttpError,\nRetryDelayStrategy,\n} from '../errors'\n-import {CommunicationObserver, Transport, SendOptions} from '../transport'\n+import {\n+ CommunicationObserver,\n+ Transport,\n+ SendOptions,\n+ Headers,\n+} from '../transport'\nimport Cancellable from '../util/Cancellable'\nimport {RetryStrategyImpl} from './retryStrategy'\n@@ -57,8 +62,7 @@ export class NodeHttpTransport implements Transport {\nprotocol: url.protocol,\nhostname: url.hostname,\n}\n- const retryJitter =\n- this.defaultOptions.retryJitter > 0 ? this.defaultOptions.retryJitter : 0\n+ const retryJitter = this.defaultOptions.retryJitter\nthis.retryStrategy = new RetryStrategyImpl({retryJitter})\nif (url.protocol === 'http:') {\nthis.requestApi = http.request\n@@ -94,6 +98,50 @@ export class NodeHttpTransport implements Transport {\nthis._request(message, cancellable, callbacks)\n}\n+ /**\n+ * Sends data to the server and receives decoded result. The type of the result depends on\n+ * response's content-type (deserialized json, text).\n+\n+ * @param path HTTP path\n+ * @param requestBody request body\n+ * @param options send options\n+ */\n+ request(path: string, body: any, options: SendOptions): Promise<any> {\n+ if (!body) {\n+ body = ''\n+ } else if (typeof body !== 'string') {\n+ body = JSON.stringify(body)\n+ }\n+ let buffer: Buffer = Buffer.alloc(0)\n+ let contentType: string\n+ return new Promise((resolve, reject) => {\n+ this.send(path, body as string, options, {\n+ responseStarted(headers: Headers) {\n+ contentType = String(headers['content-type'])\n+ },\n+ next: (data: any): void => {\n+ buffer = Buffer.concat([buffer, data as Buffer])\n+ },\n+ complete: (): void => {\n+ try {\n+ if (contentType.includes('json')) {\n+ resolve(JSON.parse(buffer.toString('utf8')))\n+ } else if (contentType.includes('text')) {\n+ resolve(buffer.toString('utf8'))\n+ } else {\n+ resolve(buffer)\n+ }\n+ } catch (e) {\n+ reject(e)\n+ }\n+ },\n+ error: (e: Error): void => {\n+ reject(e)\n+ },\n+ })\n+ })\n+ }\n+\n/**\n* Creates configuration for a specific request that encapluates everything that is\n* required to send data.\n@@ -153,6 +201,7 @@ export class NodeHttpTransport implements Transport {\nres.on('aborted', () => {\nlisteners.error(new ResponseAbortedError())\n})\n+ listeners.responseStarted(res.headers)\nconst statusCode =\nres.statusCode || /* istanbul ignore next safety check */ 600\nif (statusCode >= 300) {\n@@ -211,7 +260,7 @@ export class NodeHttpTransport implements Transport {\nrequestMessage: {[key: string]: any},\ncancellable: CancellableImpl,\ncallbacks: Partial<CommunicationObserver<any>> = {}\n- ): CommunicationObserver<any> {\n+ ): Omit<Required<CommunicationObserver<any>>, 'useCancellable'> {\nlet state = 0\nconst retVal = {\nnext: (data: any): void => {\n@@ -251,6 +300,9 @@ export class NodeHttpTransport implements Transport {\nif (callbacks.complete) callbacks.complete()\n}\n},\n+ responseStarted: (headers: Headers): void => {\n+ if (callbacks.responseStarted) callbacks.responseStarted(headers)\n+ },\n}\nreturn retVal\n}\n" }, { "change_type": "MODIFY", "old_path": "src/transport.ts", "new_path": "src/transport.ts", "diff": "import Cancellable from './util/Cancellable'\n+export type Headers = {[header: string]: string | string[] | undefined}\n+\n/**\n* Observes communication with the server.\n*/\nexport interface CommunicationObserver<T> {\n/**\n* Data chunk received, can be called mupliple times.\n+ * @param data data\n*/\nnext(data: T): void\n/**\n@@ -16,6 +19,11 @@ export interface CommunicationObserver<T> {\n* Communication was successful.\n*/\ncomplete(): void\n+ /**\n+ * Informs about a start of response processing.\n+ * @param headers response HTTP headers\n+ */\n+ responseStarted?: (headers: Headers) => void\n/**\n* Setups cancelllable for this communication.\n*/\n@@ -36,17 +44,27 @@ export interface SendOptions {\n*/\nexport interface Transport {\n/**\n- * Sends data to server and receive communication events via communication callbacks.\n+ * Send data to the server and receive communication events via callbacks.\n*\n* @param path HTTP path\n- * @param body message body\n+ * @param requestBody request body\n* @param options send options\n* @param callbacks communication callbacks with chunks of any type\n*/\nsend(\npath: string,\n- body: string,\n- options?: Partial<SendOptions>,\n+ requestBody: string,\n+ options: SendOptions,\ncallbacks?: Partial<CommunicationObserver<any>>\n): void\n+\n+ /**\n+ * Sends data to the server and receives decoded result. The type of the result depends on\n+ * response's content-type (deserialized json, text).\n+\n+ * @param path HTTP path\n+ * @param requestBody request body\n+ * @param options send options\n+ */\n+ request(path: string, body: any, options: SendOptions): Promise<any>\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -402,4 +402,123 @@ describe('NodeHttpTransport', () => {\n})\n})\n})\n+\n+ describe('request', () => {\n+ beforeEach(() => {\n+ nock.disableNetConnect()\n+ })\n+ afterEach(() => {\n+ nock.cleanAll()\n+ nock.enableNetConnect()\n+ })\n+ const transportOptions = {\n+ url: TEST_URL,\n+ timeout: 100,\n+ maxRetries: 0,\n+ }\n+ ;([\n+ [null, ''],\n+ ['', ''],\n+ ['a', 'a'],\n+ [{yes: true}, '{\"yes\":true}'],\n+ ] as Array<Array<any>>).forEach((pair, i) => {\n+ it(`returns string response ${i}`, async () => {\n+ let remainingChunks = 2\n+ let body: any = undefined\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply(\n+ 200,\n+ (_uri, requestBody) => {\n+ body = requestBody\n+ return new Readable({\n+ read(): any {\n+ remainingChunks--\n+ this.push(remainingChunks < 0 ? null : '.')\n+ },\n+ })\n+ },\n+ {\n+ 'content-type': 'text/plain',\n+ }\n+ )\n+ .persist()\n+ const retVal = await new NodeHttpTransport({\n+ ...transportOptions,\n+ timeout: 10000,\n+ maxRetries: 3,\n+ }).request('/test', pair[0], {\n+ method: 'GET',\n+ headers: {'content-type': 'text/plain'},\n+ })\n+ expect(retVal).equals('..')\n+ expect(body).equals(pair[1])\n+ })\n+ })\n+ ;([\n+ [{yes: true}, {yes: true}, 'application/json'],\n+ // eslint-disable-next-line no-undef\n+ ['abcd', Buffer.from('abcd'), 'application/binary'],\n+ ] as Array<Array<any>>).forEach(pair => {\n+ it(`returns ${pair[2]} response`, async () => {\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply(\n+ 200,\n+ (_uri, requestBody) => {\n+ return requestBody\n+ },\n+ {\n+ 'content-type': pair[2],\n+ }\n+ )\n+ .persist()\n+ const retVal = await new NodeHttpTransport({\n+ ...transportOptions,\n+ timeout: 10000,\n+ maxRetries: 3,\n+ }).request('/test', pair[0], {\n+ method: 'GET',\n+ headers: {'content-type': pair[2]},\n+ })\n+ expect(retVal).deep.equals(pair[1])\n+ })\n+ })\n+ it(`fails on invalid json`, async () => {\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply(200, '..', {\n+ 'content-type': 'application/json',\n+ })\n+ .persist()\n+ try {\n+ await new NodeHttpTransport({\n+ ...transportOptions,\n+ timeout: 10000,\n+ maxRetries: 3,\n+ }).request('/test', '', {\n+ method: 'GET',\n+ headers: {'content-type': 'applicaiton/json'},\n+ })\n+ expect.fail(`exception shall be thrown because of wrong JSON`)\n+ } catch (e) {\n+ expect(e)\n+ }\n+ })\n+ it(`fails on communication error`, async () => {\n+ try {\n+ await new NodeHttpTransport({\n+ ...transportOptions,\n+ timeout: 10000,\n+ maxRetries: 3,\n+ }).request('/test', '', {\n+ method: 'GET',\n+ headers: {'content-type': 'applicaiton/json'},\n+ })\n+ expect.fail(`exception shall be thrown because of wrong JSON`)\n+ } catch (e) {\n+ expect(e)\n+ }\n+ })\n+ })\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add request method to transport
305,159
20.12.2019 06:57:27
-3,600
a3aad20dacd8672772d248ec04159c21b21eb320
feat: simply node transport by removing retries
[ { "change_type": "MODIFY", "old_path": "src/errors.ts", "new_path": "src/errors.ts", "diff": "@@ -27,8 +27,9 @@ export interface RetriableDecision {\nretryAfter(): number\n}\n+const retriableStatusCodes = [404, 408, 425, 429, 500, 502, 503, 504]\nexport function isStatusCodeRetriable(statusCode: number): boolean {\n- return statusCode === 429 || statusCode === 503\n+ return retriableStatusCodes.includes(statusCode)\n}\nexport class IllegalArgumentError extends Error {\n" }, { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -3,13 +3,7 @@ import {parse} from 'url'\nimport * as http from 'http'\nimport * as https from 'https'\nimport {Buffer} from 'buffer'\n-import {\n- RequestTimedOutError,\n- ResponseAbortedError,\n- canRetryHttpCall,\n- HttpError,\n- RetryDelayStrategy,\n-} from '../errors'\n+import {RequestTimedOutError, ResponseAbortedError, HttpError} from '../errors'\nimport {\nCommunicationObserver,\nTransport,\n@@ -17,25 +11,15 @@ import {\nHeaders,\n} from '../transport'\nimport Cancellable from '../util/Cancellable'\n-import {RetryStrategyImpl} from './retryStrategy'\nclass CancellableImpl implements Cancellable {\nprivate cancelled = false\n- timeouts: Array<() => void> = []\ncancel(): void {\nthis.cancelled = true\n- if (this.timeouts.length > 0) {\n- this.timeouts.forEach(x => x())\n- this.timeouts = []\n- }\n}\nisCancelled(): boolean {\nreturn this.cancelled\n}\n-\n- addCancelableAction(action: () => void): void {\n- this.timeouts.push(action)\n- }\n}\n/**\n@@ -47,7 +31,6 @@ export class NodeHttpTransport implements Transport {\noptions: http.RequestOptions,\ncallback: (res: http.IncomingMessage) => void\n) => http.ClientRequest\n- retryStrategy: RetryDelayStrategy\n/**\n* Creates a node transport using for the client options supplied.\n* @param connectionOptions client options\n@@ -62,8 +45,6 @@ export class NodeHttpTransport implements Transport {\nprotocol: url.protocol,\nhostname: url.hostname,\n}\n- const retryJitter = this.defaultOptions.retryJitter\n- this.retryStrategy = new RetryStrategyImpl({retryJitter})\nif (url.protocol === 'http:') {\nthis.requestApi = http.request\n} else if (url.protocol === 'https:') {\n@@ -272,29 +253,12 @@ export class NodeHttpTransport implements Transport {\n/* istanbul ignore else propagate error at most once */\nif (state === 0) {\nstate = 1\n- if (canRetryHttpCall(error)) {\n- const retries = requestMessage.retries || 0\n- if (retries < requestMessage.maxRetries) {\n- requestMessage.retries = retries + 1\n- const cancelHandle = setTimeout(\n- () => this._request(requestMessage, cancellable, callbacks),\n- this.retryStrategy.nextDelay(error)\n- )\n- cancellable.addCancelableAction(() => {\n- /* istanbul ignore next safety check */\n- if (callbacks.complete) callbacks.complete()\n- clearTimeout(cancelHandle)\n- })\n- return\n- }\n- }\n/* istanbul ignore else safety check */\nif (callbacks.error) callbacks.error(error)\n}\n},\ncomplete: (): void => {\nif (state === 0) {\n- this.retryStrategy.success()\nstate = 2\n/* istanbul ignore else safety check */\nif (callbacks.complete) callbacks.complete()\n" }, { "change_type": "MODIFY", "old_path": "src/options.ts", "new_path": "src/options.ts", "diff": "@@ -7,18 +7,12 @@ export interface ConnectionOptions {\ntoken?: string\n/** socket timeout */\ntimeout?: number\n- /** maximum number of retries for HTTP calls that could succeed when retried */\n- maxRetries?: number\n- /** include random milliseconds when retrying HTTP calls */\n- retryJitter?: number\n/** extra options for the transport layer */\ntransportOptions?: {[key: string]: any}\n}\nexport const DEFAULT_ConnectionOptions: Partial<ConnectionOptions> = {\ntimeout: 10000,\n- maxRetries: 0,\n- retryJitter: 1000,\n}\nexport interface RetryDelayStrategyOptions {\n" }, { "change_type": "MODIFY", "old_path": "src/util/Cancellable.ts", "new_path": "src/util/Cancellable.ts", "diff": "/**\n- * Allows to cancel processing.\n+ * Performs cancellation of a running query.\n*/\nexport default interface Cancellable {\n/**\n- * Attempt to cancel execution of this query.\n+ * Attempt to cancel execution.\n*/\ncancel(): void\n- /**\n- * Is communication canceled.\n- */\nisCancelled(): boolean\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/QueryApi.test.ts", "new_path": "test/unit/QueryApi.test.ts", "diff": "@@ -12,8 +12,6 @@ const QUERY_PATH = `/api/v2/query?org=${ORG}`\nconst clientOptions: ClientOptions = {\nurl: 'http://fake:9999',\ntoken: 'a',\n- retryJitter: 0, // no retries for tests\n- maxRetries: 0,\n}\ndescribe('QueryApi', () => {\n" }, { "change_type": "MODIFY", "old_path": "test/unit/errors.test.ts", "new_path": "test/unit/errors.test.ts", "diff": "@@ -35,7 +35,7 @@ describe('errors', () => {\nnull,\nundefined,\n'whatever',\n- new HttpError(500, 'Internal Server Error', 'this is body'),\n+ new HttpError(400, 'Bad Request', 'this is body'),\nnew IllegalArgumentError('illegal argument'),\nnew Error(''),\n]\n@@ -65,7 +65,7 @@ describe('errors', () => {\nnull,\nundefined,\n'whatever',\n- new HttpError(500, 'Internal Server Error', 'this is body'),\n+ new HttpError(400, 'Bad Request', 'this is body'),\nnew IllegalArgumentError('illegal argument'),\nnew Error(''),\n]\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "import {expect} from 'chai'\nimport nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\nimport NodeHttpTransport from '../../../src/impl/NodeHttpTransport'\n-import {\n- DEFAULT_ConnectionOptions,\n- ConnectionOptions,\n-} from '../../../src/options'\n+import {ConnectionOptions} from '../../../src/options'\nimport {SendOptions} from '../../../src/transport'\nimport Cancellable from '../../../src/util/Cancellable'\nimport * as http from 'http'\n@@ -48,10 +45,8 @@ describe('NodeHttpTransport', () => {\n})\nexpect(transport.defaultOptions).to.deep.equal({\nhostname: 'test',\n- maxRetries: DEFAULT_ConnectionOptions.maxRetries,\nport: '9999',\nprotocol: 'http:',\n- retryJitter: 1000,\ntimeout: 10000,\nurl: 'http://test:9999',\n})\n@@ -63,10 +58,8 @@ describe('NodeHttpTransport', () => {\n})\nexpect(transport.defaultOptions).to.deep.equal({\nhostname: 'test',\n- maxRetries: DEFAULT_ConnectionOptions.maxRetries,\nport: '9999',\nprotocol: 'https:',\n- retryJitter: 1000,\ntimeout: 10000,\nurl: 'https://test:9999',\n})\n@@ -98,10 +91,8 @@ describe('NodeHttpTransport', () => {\n{},\n{\ntoken: 'a',\n- maxRetries: 0,\n},\n{cancel: true},\n- {maxRetries: 2, timeout: 10000},\n]\nfor (let i = 0; i < extraOptions.length; i++) {\nconst extras = extraOptions[i]\n@@ -112,18 +103,9 @@ describe('NodeHttpTransport', () => {\n() => reject(new Error('timeouted')),\n10000\n)\n- let attempts = 0\nconst context = nock(transportOptions.url)\n.post('/test')\n- .reply((_uri, _requestBody) => {\n- attempts++\n- if (extras.maxRetries && attempts <= extras.maxRetries) {\n- console.log(' ... retrying attempt ' + attempts)\n- return [429, 'yes', {'retry-after': 10}]\n- } else {\n- return [200, 'yes']\n- }\n- })\n+ .reply(200, 'yes')\n.persist()\nif (extras.token) {\ncontext.matchHeader('authorization', 'Token ' + extras.token)\n@@ -320,47 +302,22 @@ describe('NodeHttpTransport', () => {\n})\n})\n})\n- describe('canceled', () => {\n+ describe('cancelled', () => {\nconst transportOptions = {\nurl: TEST_URL,\ntimeout: 100,\nmaxRetries: 0,\n}\n- it(`is canceled before the response arrives`, async () => {\n- let cancellable: any\n+ it(`is cancelled before the response arrives`, async () => {\nnock(transportOptions.url)\n.get('/test')\n.socketDelay(2000)\n- .reply((_uri, _requestBody) => {\n- cancellable.cancel()\n- return [429, 'yes', {'retry-after': 100}]\n- })\n+ .reply(200, 'yes')\n.persist()\nawait sendTestData(\n- {...transportOptions, timeout: 1000, maxRetries: 3},\n+ {...transportOptions, timeout: 1000},\n{method: 'GET'},\n- toSet => (cancellable = toSet)\n- )\n- .then(data => {\n- expect(data).to.equal('')\n- })\n- .catch(e => {\n- throw e\n- })\n- })\n- it(`is canceled while waiting for retry`, async () => {\n- let cancellable: any\n- nock(transportOptions.url)\n- .get('/test')\n- .reply((_uri, _requestBody) => {\n- setTimeout(() => cancellable.cancel(), 50)\n- return [429, 'yes', {'retry-after': 100000}]\n- })\n- .persist()\n- await sendTestData(\n- {...transportOptions, timeout: 10000, maxRetries: 3},\n- {method: 'GET'},\n- toSet => (cancellable = toSet)\n+ cancellable => cancellable.cancel()\n)\n.then(data => {\nexpect(data).to.equal('')\n@@ -389,7 +346,7 @@ describe('NodeHttpTransport', () => {\n)\n.persist()\nawait sendTestData(\n- {...transportOptions, timeout: 10000, maxRetries: 3},\n+ {...transportOptions, timeout: 10000},\n{method: 'GET'},\ntoSet => (cancellable = toSet)\n)\n@@ -446,7 +403,6 @@ describe('NodeHttpTransport', () => {\nconst retVal = await new NodeHttpTransport({\n...transportOptions,\ntimeout: 10000,\n- maxRetries: 3,\n}).request('/test', pair[0], {\nmethod: 'GET',\nheaders: {'content-type': 'text/plain'},\n@@ -476,7 +432,6 @@ describe('NodeHttpTransport', () => {\nconst retVal = await new NodeHttpTransport({\n...transportOptions,\ntimeout: 10000,\n- maxRetries: 3,\n}).request('/test', pair[0], {\nmethod: 'GET',\nheaders: {'content-type': pair[2]},\n@@ -495,7 +450,6 @@ describe('NodeHttpTransport', () => {\nawait new NodeHttpTransport({\n...transportOptions,\ntimeout: 10000,\n- maxRetries: 3,\n}).request('/test', '', {\nmethod: 'GET',\nheaders: {'content-type': 'applicaiton/json'},\n@@ -510,7 +464,6 @@ describe('NodeHttpTransport', () => {\nawait new NodeHttpTransport({\n...transportOptions,\ntimeout: 10000,\n- maxRetries: 3,\n}).request('/test', '', {\nmethod: 'GET',\nheaders: {'content-type': 'applicaiton/json'},\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/impl/WriteApiImpl.test.ts", "diff": "@@ -14,7 +14,6 @@ import {collectLogging, CollectedLogs} from '../../util'\nconst clientOptions: ClientOptions = {\nurl: 'http://fake:9999',\ntoken: 'a',\n- retryJitter: 0, // minimum delay for tests\n}\nconst transport = new NodeHttpTransport(clientOptions)\nconst ORG = 'org'\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: simply node transport by removing retries
305,159
20.12.2019 10:09:55
-3,600
3f44364543252cfe5f5f766e43503b7ab1cd8c0b
feat: process gzip response encoding
[ { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -11,6 +11,12 @@ import {\nHeaders,\n} from '../transport'\nimport Cancellable from '../util/Cancellable'\n+import zlib from 'zlib'\n+\n+const zlibOptions = {\n+ flush: zlib.Z_SYNC_FLUSH,\n+ finishFlush: zlib.Z_SYNC_FLUSH,\n+}\nclass CancellableImpl implements Cancellable {\nprivate cancelled = false\n@@ -185,16 +191,25 @@ export class NodeHttpTransport implements Transport {\nlisteners.responseStarted(res.headers)\nconst statusCode =\nres.statusCode || /* istanbul ignore next safety check */ 600\n+ const contentEncoding = res.headers['content-encoding']\n+ let responseData\n+ if (contentEncoding === 'gzip') {\n+ responseData = zlib.createGunzip(zlibOptions)\n+ res.pipe(responseData)\n+ } else {\n+ responseData = res\n+ }\n+ responseData.on('error', listeners.error)\nif (statusCode >= 300) {\nlet body = ''\n- res.on('data', s => {\n+ responseData.on('data', s => {\nbody += s.toString()\nif (body.length > 1000) {\nbody = body.slice(0, 1000)\nres.resume()\n}\n})\n- res.on('end', () =>\n+ responseData.on('end', () =>\nlisteners.error(\nnew HttpError(\nstatusCode,\n@@ -205,14 +220,14 @@ export class NodeHttpTransport implements Transport {\n)\n)\n} else {\n- res.on('data', data => {\n+ responseData.on('data', data => {\nif (cancellable.isCancelled()) {\nres.resume()\n} else {\nlisteners.next(data)\n}\n})\n- res.on('end', listeners.complete)\n+ responseData.on('end', listeners.complete)\n}\n})\n// Support older Nodes which don't allow .timeout() in the\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/NodeHttpTransport.test.ts", "new_path": "test/unit/impl/NodeHttpTransport.test.ts", "diff": "@@ -8,6 +8,7 @@ import * as http from 'http'\nimport * as https from 'https'\nimport sinon from 'sinon'\nimport {Readable} from 'stream'\n+import zlib from 'zlib'\nfunction sendTestData(\nconnectionOptions: ConnectionOptions,\n@@ -93,9 +94,15 @@ describe('NodeHttpTransport', () => {\ntoken: 'a',\n},\n{cancel: true},\n+ {\n+ headers: {\n+ 'accept-encoding': 'gzip',\n+ },\n+ },\n]\nfor (let i = 0; i < extraOptions.length; i++) {\nconst extras = extraOptions[i]\n+ const responseData = 'yes'\nit(`works with options ${JSON.stringify(extras)}`, async () => {\nconst nextFn = sinon.fake()\nawait new Promise<void>((resolve, reject) => {\n@@ -103,9 +110,33 @@ describe('NodeHttpTransport', () => {\n() => reject(new Error('timeouted')),\n10000\n)\n+ let responseRead = false\nconst context = nock(transportOptions.url)\n.post('/test')\n- .reply(200, 'yes')\n+ .reply((_uri, _requestBody) => [\n+ 200,\n+ new Readable({\n+ read(): any {\n+ const encode = !!(extras.headers || {})['accept-encoding']\n+ if (encode) {\n+ this.push(\n+ responseRead ? null : zlib.gzipSync(responseData)\n+ )\n+ } else {\n+ this.push(responseRead ? null : responseData)\n+ }\n+ responseRead = true\n+ },\n+ }),\n+ {\n+ 'content-encoding': (\n+ _req: any,\n+ _res: any,\n+ _body: any\n+ ): string =>\n+ (extras.headers || {})['accept-encoding'] || 'identity',\n+ },\n+ ])\n.persist()\nif (extras.token) {\ncontext.matchHeader('authorization', 'Token ' + extras.token)\n@@ -122,9 +153,9 @@ describe('NodeHttpTransport', () => {\nnext(data: any) {\nnextFn(data)\n},\n- error(_error: any) {\n+ error(error: any) {\nclearTimeout(timeout)\n- reject(new Error('No error expected!'))\n+ reject(new Error('No error expected!, but: ' + error))\n},\ncomplete(): void {\nclearTimeout(timeout)\n@@ -138,13 +169,16 @@ describe('NodeHttpTransport', () => {\nif (extras.cancel) {\ncancellable.cancel()\n}\n- }).then(() => {\n+ })\n+ .then(() => {\nexpect(nextFn.called)\nif (!extras.cancel) {\n- expect(nextFn.args[0][0].toString()).to.equal('yes')\n+ expect(nextFn.args[0][0].toString()).to.equal(responseData)\n}\n})\n- // .catch(e => expect.fail(undefined, e, e.toString()))\n+ .catch(e => {\n+ expect.fail(undefined, e, e.toString())\n+ })\n})\n}\n})\n@@ -170,7 +204,7 @@ describe('NodeHttpTransport', () => {\n.reply(500, 'not ok')\nawait sendTestData(transportOptions, {method: 'GET'})\n.then(() => {\n- throw new Error('must not succeed')\n+ expect.fail('must not succeed')\n})\n.catch(e => {\nexpect(e)\n@@ -178,6 +212,34 @@ describe('NodeHttpTransport', () => {\n.to.equal(500)\n})\n})\n+ it(`fails on decoding error`, async () => {\n+ let responseRead = false\n+ nock(transportOptions.url)\n+ .get('/test')\n+ .reply((_uri, _requestBody) => [\n+ 200,\n+ new Readable({\n+ read(): any {\n+ this.push(responseRead ? null : 'no')\n+ responseRead = true\n+ },\n+ }),\n+ {\n+ 'content-encoding': 'gzip',\n+ },\n+ ])\n+ .persist()\n+ await sendTestData(transportOptions, {method: 'GET'})\n+ .then(() => {\n+ expect.fail('must not succeed')\n+ })\n+ .catch(e => {\n+ expect(e)\n+ .property('message')\n+ .is.not.equal('must not succeed')\n+ expect(e.toString()).does.not.include('time') // not timeout\n+ })\n+ })\nit(`fails on socket timeout`, async () => {\nnock(transportOptions.url)\n.get('/test')\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: process gzip response encoding
305,159
20.12.2019 10:32:19
-3,600
1c9ba451a5ab02c4e0a60a7e242a80db10f9d19a
feat(query): alllow to control accept-encoding of query responses with a gzip flag
[ { "change_type": "MODIFY", "old_path": "src/QueryApi.ts", "new_path": "src/QueryApi.ts", "diff": "@@ -22,6 +22,10 @@ export interface QueryOptions {\n* Required only for \"influxql\" queries.\n*/\nrp?: string\n+ /**\n+ * Requests gzip encoded response.\n+ */\n+ gzip?: boolean\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "src/impl/QueryApiImpl.ts", "new_path": "src/impl/QueryApiImpl.ts", "diff": "@@ -35,6 +35,7 @@ export class QueryApiImpl implements QueryApi {\nmethod: 'POST',\nheaders: {\n'content-type': 'application/json; encoding=utf-8',\n+ 'accept-encoding': this.options.gzip ? 'gzip' : 'identity',\n},\n},\nnew ChunksToLines(consumer)\n" }, { "change_type": "MODIFY", "old_path": "test/unit/QueryApi.test.ts", "new_path": "test/unit/QueryApi.test.ts", "diff": "@@ -5,6 +5,7 @@ import fs from 'fs'\nimport {CollectLinesObserver} from './util/CollectLinesObserver'\nimport {CollectTablesObserver} from './util/CollectTablesObserver'\nimport simpleResponseLines from '../fixture/query/simpleResponseLines.json'\n+import zlib from 'zlib'\nconst ORG = `my-org`\nconst QUERY_PATH = `/api/v2/query?org=${ORG}`\n@@ -44,13 +45,23 @@ describe('QueryApi', () => {\nexpect(target.completed).to.equals(1)\nexpect(target.lines).to.deep.equal(simpleResponseLines)\n})\n- ;['response2', 'response3'].forEach((name: string) => {\n- it(`receives tables from ${name}`, async () => {\n- const subject = new InfluxDB(clientOptions).getQueryApi(ORG).with({})\n+ ;[\n+ ['response2', undefined],\n+ ['response2', true],\n+ ['response3', false],\n+ ].forEach(([name, gzip]) => {\n+ it(`receives tables from ${name} with gzip=${gzip}`, async () => {\n+ const subject = new InfluxDB(clientOptions)\n+ .getQueryApi(ORG)\n+ .with({gzip: gzip as boolean | undefined})\nnock(clientOptions.url)\n.post(QUERY_PATH)\n.reply((_uri, _requestBody) => {\n- return [200, fs.createReadStream(`test/fixture/query/${name}.txt`)]\n+ let stream: any = fs.createReadStream(\n+ `test/fixture/query/${name}.txt`\n+ )\n+ if (gzip) stream = stream.pipe(zlib.createGzip())\n+ return [200, stream, {'content-encoding': gzip ? 'gzip' : 'identity'}]\n})\n.persist()\nconst target = new CollectTablesObserver()\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(query): alllow to control accept-encoding of query responses with a gzip flag
305,159
20.12.2019 10:52:54
-3,600
b12ba409428fc9bb4958711425a4c2f43d5b958f
feat(write): isolate write tests
[ { "change_type": "MODIFY", "old_path": "src/WriteApi.ts", "new_path": "src/WriteApi.ts", "diff": "@@ -12,7 +12,7 @@ export default interface WriteApi {\n* Not applicable for writing records/lines.\n* @param tags\n*/\n- useDefaultTags(tags: {[key: string]: string}): void\n+ useDefaultTags(tags: {[key: string]: string}): WriteApi\n/**\n* Write a line of <a href=\"https://bit.ly/2QL99fu\">Line Protocol</a>.\n" }, { "change_type": "RENAME", "old_path": "test/unit/impl/WriteApiImpl.test.ts", "new_path": "test/unit/WriteApi.test.ts", "diff": "import {expect} from 'chai'\nimport nock from 'nock' // WARN: nock must be imported before NodeHttpTransport, since it modifies node's http\n-import NodeHttpTransport from '../../../src/impl/NodeHttpTransport'\nimport {\nClientOptions,\nWritePrecision,\nWriteOptions,\nPoint,\nWriteApi,\n-} from '../../../src'\n-import WriteApiImpl from '../../../src/impl/WriteApiImpl'\n-import {collectLogging, CollectedLogs} from '../../util'\n+ InfluxDB,\n+} from '../../src'\n+import {collectLogging, CollectedLogs} from '../util'\nconst clientOptions: ClientOptions = {\nurl: 'http://fake:9999',\ntoken: 'a',\n}\n-const transport = new NodeHttpTransport(clientOptions)\nconst ORG = 'org'\nconst BUCKET = 'bucket'\nconst PRECISION = WritePrecision.s\nconst WRITE_PATH_NS = `/api/v2/write?org=${ORG}&bucket=${BUCKET}&precision=ns`\n-describe('WriteApiImpl', () => {\n+function createApi(\n+ org: string,\n+ bucket: string,\n+ precision: WritePrecision,\n+ options: Partial<WriteOptions>\n+): WriteApi {\n+ return new InfluxDB({\n+ ...clientOptions,\n+ ...{writeOptions: options},\n+ }).getWriteApi(org, bucket, precision)\n+}\n+\n+describe('WriteApi', () => {\nbeforeEach(() => {\nnock.disableNetConnect()\n})\n@@ -31,10 +41,10 @@ describe('WriteApiImpl', () => {\nnock.enableNetConnect()\n})\ndescribe('simple', () => {\n- let subject: WriteApiImpl\n+ let subject: WriteApi\nlet logs: CollectedLogs\nbeforeEach(() => {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n+ subject = createApi(ORG, BUCKET, PRECISION, {\nretryJitter: 0,\n})\n// logs = collectLogging.decorate()\n@@ -72,10 +82,10 @@ describe('WriteApiImpl', () => {\n})\n})\ndescribe('configuration', () => {\n- let subject: WriteApiImpl\n+ let subject: WriteApi\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n+ subject = createApi(ORG, BUCKET, PRECISION, {\nretryJitter: 0,\n...writeOptions,\n})\n@@ -125,10 +135,10 @@ describe('WriteApiImpl', () => {\n})\n})\ndescribe('flush on background', () => {\n- let subject: WriteApiImpl\n+ let subject: WriteApi\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, PRECISION, {\n+ subject = createApi(ORG, BUCKET, PRECISION, {\nretryJitter: 0,\n...writeOptions,\n})\n@@ -159,7 +169,7 @@ describe('WriteApiImpl', () => {\nlet subject: WriteApi\nlet logs: CollectedLogs\nfunction useSubject(writeOptions: Partial<WriteOptions>): void {\n- subject = new WriteApiImpl(transport, ORG, BUCKET, WritePrecision.ns, {\n+ subject = createApi(ORG, BUCKET, WritePrecision.ns, {\nretryJitter: 0,\n...writeOptions,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(write): isolate write tests
305,159
02.01.2020 10:09:49
-3,600
88c0fa06986552b473fb84a76fc911c797d54178
feat(transport): remove maxRetries from SendOptions
[ { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -158,8 +158,6 @@ export class NodeHttpTransport implements Transport {\nif (this.connectionOptions.token) {\noptions.headers.authorization = 'Token ' + this.connectionOptions.token\n}\n- if (sendOptions.maxRetries !== undefined)\n- options.maxRetries = sendOptions.maxRetries\noptions.headers['content-length'] = bodyBuffer.length\nreturn options\n" }, { "change_type": "MODIFY", "old_path": "src/impl/WriteApiImpl.ts", "new_path": "src/impl/WriteApiImpl.ts", "diff": "@@ -60,7 +60,6 @@ export default class WriteApiImpl implements WriteApi, PointSettings {\nprivate writeOptions: WriteOptions\nprivate sendOptions: SendOptions = {\nmethod: 'POST',\n- maxRetries: 0, // we control manual retry attempts\nheaders: {\n'content-type': 'text/plain; charset=utf-8',\n},\n" }, { "change_type": "MODIFY", "old_path": "src/transport.ts", "new_path": "src/transport.ts", "diff": "@@ -35,7 +35,6 @@ export interface CommunicationObserver<T> {\n*/\nexport interface SendOptions {\nmethod: string\n- maxRetries?: number\nheaders?: {[key: string]: string}\n}\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(transport): remove maxRetries from SendOptions
305,159
02.01.2020 13:01:45
-3,600
1e5c6ff652d8168311c981bfd6a157e5bee64992
feat(query): remove query API dependency on node Buffer
[ { "change_type": "MODIFY", "old_path": "src/impl/ChunksToLines.ts", "new_path": "src/impl/ChunksToLines.ts", "diff": "-import {CommunicationObserver} from '../transport'\n+import {CommunicationObserver, ChunkCombiner} from '../transport'\nimport Cancellable from '../util/Cancellable'\n-import {Buffer} from 'buffer'\n+\n/**\n* Converts lines to table calls\n*/\nexport default class ChunksToLines implements CommunicationObserver<any> {\n- previous?: Buffer\n+ previous?: Uint8Array\nfinished = false\n- constructor(private target: CommunicationObserver<string>) {}\n+ constructor(\n+ private target: CommunicationObserver<string>,\n+ private chunks: ChunkCombiner\n+ ) {}\nnext(chunk: any): void {\nif (this.finished) return\n- if (Buffer.isBuffer(chunk)) {\n+ try {\nthis.bufferReceived(chunk)\n- } else {\n- this.error(new Error('Only node buffer chunks are supported!'))\n+ } catch (e) {\n+ this.error(e)\n}\n}\nerror(error: Error): void {\n@@ -27,7 +30,7 @@ export default class ChunksToLines implements CommunicationObserver<any> {\ncomplete(): void {\nif (!this.finished) {\nif (this.previous) {\n- this.target.next(this.previous.toString('utf8'))\n+ this.target.next(this.chunks.toUtf8String(this.previous))\n}\nthis.finished = true\nthis.target.complete()\n@@ -37,11 +40,11 @@ export default class ChunksToLines implements CommunicationObserver<any> {\nthis.target.useCancellable && this.target.useCancellable(cancellable)\n}\n- private bufferReceived(chunk: Buffer): void {\n+ private bufferReceived(chunk: any): void {\nlet index: number\nlet start = 0\nif (this.previous) {\n- chunk = Buffer.concat([this.previous as Buffer, chunk])\n+ chunk = this.chunks.concat(this.previous, chunk)\nindex = (this.previous as Buffer).length\n} else {\nindex = 0\n@@ -53,7 +56,7 @@ export default class ChunksToLines implements CommunicationObserver<any> {\nif (!quoted) {\n/* do not emit CR+LR or LF line ending */\nconst end = index > 0 && chunk[index - 1] === 13 ? index - 1 : index\n- this.target.next(chunk.toString('utf8', start, end))\n+ this.target.next(this.chunks.toUtf8String(chunk, start, end))\nstart = index + 1\n}\n} else if (c === 34 /* \" */) {\n@@ -62,8 +65,7 @@ export default class ChunksToLines implements CommunicationObserver<any> {\nindex++\n}\nif (start < index) {\n- this.previous = Buffer.allocUnsafe(index - start)\n- chunk.copy(this.previous, 0, start, index)\n+ this.previous = this.chunks.copy(chunk.slice(start, index))\n} else {\nthis.previous = undefined\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -9,14 +9,17 @@ import {\nTransport,\nSendOptions,\nHeaders,\n+ ChunkCombiner,\n} from '../transport'\nimport Cancellable from '../util/Cancellable'\n+import nodeChunkCombiner from './nodeChunkCombiner'\nimport zlib from 'zlib'\nconst zlibOptions = {\nflush: zlib.Z_SYNC_FLUSH,\nfinishFlush: zlib.Z_SYNC_FLUSH,\n}\n+const emptyBuffer = Buffer.allocUnsafe(0)\nclass CancellableImpl implements Cancellable {\nprivate cancelled = false\n@@ -32,6 +35,9 @@ class CancellableImpl implements Cancellable {\n* Transport layer on top of node http or https library.\n*/\nexport class NodeHttpTransport implements Transport {\n+ /* required transport member */\n+ readonly chunkCombiner: ChunkCombiner = nodeChunkCombiner\n+\nprivate defaultOptions: {[key: string]: any}\nprivate requestApi: (\noptions: http.RequestOptions,\n@@ -99,7 +105,7 @@ export class NodeHttpTransport implements Transport {\n} else if (typeof body !== 'string') {\nbody = JSON.stringify(body)\n}\n- let buffer: Buffer = Buffer.alloc(0)\n+ let buffer = emptyBuffer\nlet contentType: string\nreturn new Promise((resolve, reject) => {\nthis.send(path, body as string, options, {\n" }, { "change_type": "MODIFY", "old_path": "src/impl/QueryApiImpl.ts", "new_path": "src/impl/QueryApiImpl.ts", "diff": "@@ -38,7 +38,7 @@ export class QueryApiImpl implements QueryApi {\n'accept-encoding': this.options.gzip ? 'gzip' : 'identity',\n},\n},\n- new ChunksToLines(consumer)\n+ new ChunksToLines(consumer, this.transport.chunkCombiner)\n)\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "src/impl/nodeChunkCombiner.ts", "diff": "+import {ChunkCombiner} from '../transport'\n+import {Buffer} from 'buffer'\n+\n+const nodeChunkCombiner: ChunkCombiner = {\n+ concat(first: Uint8Array, second: Uint8Array): Uint8Array {\n+ return Buffer.concat([first, second])\n+ },\n+ toUtf8String(chunk: Uint8Array, start?: number, end?: number): string {\n+ return (chunk as Buffer).toString('utf-8', start, end)\n+ },\n+ copy(chunk: Uint8Array): Uint8Array {\n+ const retVal = Buffer.allocUnsafe(chunk.length)\n+ ;(chunk as Buffer).copy(retVal, 0, 0, chunk.length)\n+ return retVal\n+ },\n+}\n+\n+export default nodeChunkCombiner\n" }, { "change_type": "MODIFY", "old_path": "src/transport.ts", "new_path": "src/transport.ts", "diff": "@@ -38,6 +38,29 @@ export interface SendOptions {\nheaders?: {[key: string]: string}\n}\n+/**\n+ * Simpified platform-neutral data chunk manipulation.\n+ */\n+export interface ChunkCombiner {\n+ /**\n+ * Concatenates first and second chunk.\n+ * @param first chunk\n+ * @param second chunk\n+ * @return first + second\n+ */\n+ concat(first: Uint8Array, second: Uint8Array): Uint8Array\n+\n+ /**\n+ * Converts chunk into a string.\n+ */\n+ toUtf8String(chunk: Uint8Array, start?: number, end?: number): string\n+\n+ /**\n+ * Creates a new chunk from the supplied chunk.\n+ */\n+ copy(chunk: Uint8Array): Uint8Array\n+}\n+\n/**\n* Simpified platform-neutral transport layer for communication with influx DB.\n*/\n@@ -66,4 +89,9 @@ export interface Transport {\n* @param options send options\n*/\nrequest(path: string, body: any, options: SendOptions): Promise<any>\n+\n+ /**\n+ * Returns operations for chunks emitted to the {@link send} method communication observer.\n+ */\n+ readonly chunkCombiner: ChunkCombiner\n}\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/ChunksToLines.test.ts", "new_path": "test/unit/impl/ChunksToLines.test.ts", "diff": "@@ -4,6 +4,8 @@ import chunksToLinesTables from '../../fixture/chunksToLinesTables.json'\nimport Cancellable from '../../../src/util/Cancellable'\nimport sinon from 'sinon'\nimport {CollectLinesObserver} from '../util/CollectLinesObserver'\n+import nodeChunkCombiner from '../../../src/impl/nodeChunkCombiner'\n+import {Buffer} from 'buffer'\ninterface ChunkTest {\nname: string\n@@ -24,7 +26,7 @@ describe('ChunksToLines', () => {\nconst target = test.withCancellable\n? new CollectLinesObserver2()\n: new CollectLinesObserver()\n- const subject = new ChunksToLines(target)\n+ const subject = new ChunksToLines(target, nodeChunkCombiner)\nsubject.useCancellable({isCancelled: sinon.mock(), cancel: sinon.mock()})\nlet failed = false\nfor (let i = 0; i < test.chunks.length; i++) {\n@@ -49,7 +51,8 @@ describe('ChunksToLines', () => {\n})\nit('fails on unsupported data', () => {\nconst target = new CollectLinesObserver()\n- const subject = new ChunksToLines(target)\n+ const subject = new ChunksToLines(target, nodeChunkCombiner)\n+ subject.next(Buffer.from('abcd', 'utf8'))\nsubject.next(1)\nexpect(target.failed).to.be.equal(1)\n})\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/linesToTables.test.ts", "new_path": "test/unit/impl/linesToTables.test.ts", "diff": "@@ -3,6 +3,7 @@ import fs from 'fs'\nimport {CollectTablesObserver} from '../util/CollectTablesObserver'\nimport {toLineObserver} from '../../../src/impl/linesToTables'\nimport ChunksToLines from '../../../src/impl/ChunksToLines'\n+import nodeChunkCombiner from '../../../src/impl/nodeChunkCombiner'\ndescribe('linesToTables', () => {\nit('parses tables', async () => {\n@@ -12,7 +13,7 @@ describe('linesToTables', () => {\n)\nconst target = new CollectTablesObserver()\nconst lineObserver = toLineObserver(target)\n- const input = new ChunksToLines(lineObserver)\n+ const input = new ChunksToLines(lineObserver, nodeChunkCombiner)\ninput.next(data)\nexpect(target.completed).equals(0)\nexpect(target.tables).deep.equal(response.tables)\n@@ -25,7 +26,7 @@ describe('linesToTables', () => {\n;(target as any).useCancellable = (_x: any): void => {}\nconst lineObserver = toLineObserver(target)\n- const input = new ChunksToLines(lineObserver)\n+ const input = new ChunksToLines(lineObserver, nodeChunkCombiner)\ninput.useCancellable({\ncancel(): void {},\nisCancelled(): boolean {\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(query): remove query API dependency on node Buffer
305,159
02.01.2020 13:15:56
-3,600
125de9312d1579847c8fe388062f4d40ccb7b04d
chore: add no-console to lint
[ { "change_type": "MODIFY", "old_path": ".eslintrc.json", "new_path": ".eslintrc.json", "diff": "\"prettier/@typescript-eslint\"\n],\n\"rules\": {\n+ \"no-console\": \"warn\",\n\"@typescript-eslint/camelcase\": [\"error\", {\"allow\": [\"^DEFAULT_\"]}],\n\"@typescript-eslint/no-explicit-any\": \"off\",\n\"@typescript-eslint/no-unused-vars\": [\n" }, { "change_type": "MODIFY", "old_path": "src/impl/Logger.ts", "new_path": "src/impl/Logger.ts", "diff": "@@ -11,9 +11,11 @@ export interface Logger {\n*/\nexport const consoleLogger: Logger = Object.freeze({\nerror(message, error) {\n+ // eslint-disable-next-line no-console\nconsole.error('ERROR: ' + message, error ? error : '')\n},\nwarn(message, error) {\n+ // eslint-disable-next-line no-console\nconsole.warn('WARN: ' + message, error ? error : '')\n},\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
chore: add no-console to lint
305,159
02.01.2020 15:15:46
-3,600
0ac15de7d6414c9c55c7548ba3b57436dbd04141
feat: optimize ChunkCombiner
[ { "change_type": "MODIFY", "old_path": "src/impl/ChunksToLines.ts", "new_path": "src/impl/ChunksToLines.ts", "diff": "@@ -30,7 +30,9 @@ export default class ChunksToLines implements CommunicationObserver<any> {\ncomplete(): void {\nif (!this.finished) {\nif (this.previous) {\n- this.target.next(this.chunks.toUtf8String(this.previous))\n+ this.target.next(\n+ this.chunks.toUtf8String(this.previous, 0, this.previous.length)\n+ )\n}\nthis.finished = true\nthis.target.complete()\n@@ -65,7 +67,7 @@ export default class ChunksToLines implements CommunicationObserver<any> {\nindex++\n}\nif (start < index) {\n- this.previous = this.chunks.copy(chunk.slice(start, index))\n+ this.previous = this.chunks.copy(chunk, start, index)\n} else {\nthis.previous = undefined\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/nodeChunkCombiner.ts", "new_path": "src/impl/nodeChunkCombiner.ts", "diff": "@@ -5,12 +5,12 @@ const nodeChunkCombiner: ChunkCombiner = {\nconcat(first: Uint8Array, second: Uint8Array): Uint8Array {\nreturn Buffer.concat([first, second])\n},\n- toUtf8String(chunk: Uint8Array, start?: number, end?: number): string {\n+ toUtf8String(chunk: Uint8Array, start: number, end: number): string {\nreturn (chunk as Buffer).toString('utf-8', start, end)\n},\n- copy(chunk: Uint8Array): Uint8Array {\n- const retVal = Buffer.allocUnsafe(chunk.length)\n- ;(chunk as Buffer).copy(retVal, 0, 0, chunk.length)\n+ copy(chunk: Uint8Array, start: number, end: number): Uint8Array {\n+ const retVal = Buffer.allocUnsafe(end - start)\n+ ;(chunk as Buffer).copy(retVal, 0, start, end)\nreturn retVal\n},\n}\n" }, { "change_type": "MODIFY", "old_path": "src/transport.ts", "new_path": "src/transport.ts", "diff": "@@ -53,12 +53,12 @@ export interface ChunkCombiner {\n/**\n* Converts chunk into a string.\n*/\n- toUtf8String(chunk: Uint8Array, start?: number, end?: number): string\n+ toUtf8String(chunk: Uint8Array, start: number, end: number): string\n/**\n* Creates a new chunk from the supplied chunk.\n*/\n- copy(chunk: Uint8Array): Uint8Array\n+ copy(chunk: Uint8Array, start: number, end: number): Uint8Array\n}\n/**\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: optimize ChunkCombiner
305,159
02.01.2020 20:25:53
-3,600
8184d6ec9d5351a5c33208969ffab09bfe6592f7
feat: add pure JS chunk combiner
[ { "change_type": "ADD", "old_path": null, "new_path": "src/impl/pureJsChunkCombiner.ts", "diff": "+import {ChunkCombiner} from '../transport'\n+\n+const pureJsChunkCombiner: ChunkCombiner = {\n+ concat(first: Uint8Array, second: Uint8Array): Uint8Array {\n+ const retVal = new Uint8Array(first.length + second.length)\n+ retVal.set(first)\n+ retVal.set(second, first.length)\n+ return retVal\n+ },\n+ toUtf8String(chunk: Uint8Array, start: number, end: number): string {\n+ // see https://en.wikipedia.org/wiki/UTF-8 for details\n+ let c1, c2, c3, c4\n+ let out = ''\n+ let i = start\n+ while (i < end) {\n+ c1 = chunk[i++]\n+ switch (c1 >> 4) {\n+ case 0:\n+ case 1:\n+ case 2:\n+ case 3:\n+ case 4:\n+ case 5:\n+ case 6:\n+ case 7:\n+ // 0xxxxxxx\n+ out += String.fromCharCode(c1)\n+ break\n+ case 12:\n+ case 13:\n+ // 110x xxxx 10xx xxxx\n+ c2 = chunk[i++]\n+ out += String.fromCharCode(((c1 & 0x1f) << 6) | (c2 & 0x3f))\n+ break\n+ case 14:\n+ // 1110 xxxx 10xx xxxx 10xx xxxx\n+ c2 = chunk[i++]\n+ c3 = chunk[i++]\n+ out += String.fromCharCode(\n+ ((c1 & 0x0f) << 12) | ((c2 & 0x3f) << 6) | (c3 & 0x3f)\n+ )\n+ break\n+ case 15:\n+ // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx\n+ c2 = chunk[i++]\n+ c3 = chunk[i++]\n+ c4 = chunk[i++]\n+ out += String.fromCodePoint(\n+ ((c1 & 0x07) << 18) |\n+ ((c2 & 0x3f) << 12) |\n+ ((c3 & 0x3f) << 6) |\n+ (c4 & 0x3f)\n+ )\n+ break\n+ }\n+ }\n+ return out\n+ },\n+\n+ copy(chunk: Uint8Array, start: number, end: number): Uint8Array {\n+ const retVal = new Uint8Array(end - start)\n+ retVal.set(chunk.slice(start, end))\n+ return retVal\n+ },\n+}\n+\n+export default pureJsChunkCombiner\n" }, { "change_type": "ADD", "old_path": null, "new_path": "test/unit/impl/pureJsChunkCombiner.test.ts", "diff": "+import {expect} from 'chai'\n+import pureJsChunkCombiner from '../../../src/impl/pureJsChunkCombiner'\n+\n+describe('pureJsChunkCombiner', () => {\n+ it('concatenates chunks', () => {\n+ expect(\n+ pureJsChunkCombiner.concat(\n+ Uint8Array.from([1, 2]),\n+ Uint8Array.from([3, 4])\n+ )\n+ ).is.deep.equal(Uint8Array.from([1, 2, 3, 4]))\n+ expect(\n+ pureJsChunkCombiner.concat(Uint8Array.from([]), Uint8Array.from([3, 4]))\n+ ).is.deep.equal(Uint8Array.from([3, 4]))\n+ })\n+ it('copies chunks', () => {\n+ const src = Uint8Array.from([1, 2])\n+ const copy = pureJsChunkCombiner.copy(src, 1, 2)\n+ expect(copy).is.deep.equal(Uint8Array.from([2]))\n+ src[1] = 3\n+ expect(copy[0]).is.equal(2)\n+ })\n+ // see examples in https://en.wikipedia.org/wiki/UTF-8\n+ const chunks = [\n+ ...[0, 1, 2, 3, 4, 5, 6, 7].map(num => [\n+ String.fromCharCode(num << 4),\n+ Uint8Array.from([num << 4]),\n+ ]),\n+ ['$', Uint8Array.from([0x24])],\n+ ['\\u{A2}', Uint8Array.from([0xc2, 0xa2])],\n+ ['\\u{4FF}', Uint8Array.from([0xd3, 0xbf])],\n+ ['\\u{939}', Uint8Array.from([0xe0, 0xa4, 0xb9])],\n+ ['\\u{10348}', Uint8Array.from([0xf0, 0x90, 0x8d, 0x88])],\n+ ]\n+ chunks.forEach(([str, chunk]) => {\n+ it(`utf-8 encodes chunk ${str}`, () => {\n+ // console.log(Buffer.from(str as string, 'utf8'))\n+ const encoded = pureJsChunkCombiner.toUtf8String(\n+ chunk as Uint8Array,\n+ 0,\n+ chunk.length\n+ )\n+ expect(encoded).equals(str)\n+ })\n+ })\n+})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: add pure JS chunk combiner
305,159
05.01.2020 10:10:39
-3,600
c6644d10a80d209332b34f253aaf9be23b3309c8
feat(setup): simplify API, add documentation
[ { "change_type": "MODIFY", "old_path": "examples/setupInfluxDB.ts", "new_path": "examples/setupInfluxDB.ts", "diff": "@@ -11,8 +11,8 @@ import {url, username, password, org, bucket, token} from './env'\nconst setupApi = new InfluxDB({url}).getSetupApi()\nsetupApi\n- .isOnboarded()\n- .then(async ({allowed: allowed}) => {\n+ .isOnboarding()\n+ .then(async allowed => {\nif (allowed) {\nconst response = await setupApi.setup(\n{org, bucket, username, password},\n" }, { "change_type": "MODIFY", "old_path": "src/SetupApi.ts", "new_path": "src/SetupApi.ts", "diff": "-import {\n- IsOnboarding,\n- OnboardingResponse,\n- OnboardingRequest,\n-} from './generated/types'\n+import {OnboardingResponse, OnboardingRequest} from './generated/types'\n/**\n* See <a href=\"https://v2.docs.influxdata.com/v2.0/api/#tag/Setup\">https://v2.docs.influxdata.com/v2.0/api/#tag/Setup</a>.\n*/\nexport default interface SetupApi {\n- isOnboarded(): Promise<IsOnboarding>\n+ /**\n+ * Is on-boarding still allowed.\n+ * @return false if it was already performed\n+ */\n+ isOnboarding(): Promise<boolean>\n+ /**\n+ * Setups a (new) influx DB instance.\n+ * @param request default user and password, organization, bucket\n+ * @param token optional authentication token to be used with that user\n+ */\nsetup(request: OnboardingRequest, token?: string): Promise<OnboardingResponse>\n}\n" }, { "change_type": "MODIFY", "old_path": "src/impl/SetupApiImpl.ts", "new_path": "src/impl/SetupApiImpl.ts", "diff": "import SetupApi from '../SetupApi'\nimport {Transport} from '../transport'\n-import {\n- IsOnboarding,\n- OnboardingResponse,\n- OnboardingRequest,\n-} from '../generated/types'\n+import {OnboardingResponse, OnboardingRequest} from '../generated/types'\nexport default class SetupApiImpl implements SetupApi {\nconstructor(private transport: Transport) {}\n- isOnboarded(): Promise<IsOnboarding> {\n- return this.transport.request('/api/v2/setup', '', {method: 'GET'})\n+ async isOnboarding(): Promise<boolean> {\n+ const x = await this.transport.request('/api/v2/setup', '', {method: 'GET'})\n+ return x.allowed as boolean\n}\nsetup(\nrequest: OnboardingRequest,\n" }, { "change_type": "MODIFY", "old_path": "test/unit/SetupApi.test.ts", "new_path": "test/unit/SetupApi.test.ts", "diff": "@@ -17,16 +17,14 @@ describe('SetupApi', () => {\nnock.cleanAll()\nnock.enableNetConnect()\n})\n- it('isOnboarded', async () => {\n+ it('isOnboarding', async () => {\nnock(url)\n.get('/api/v2/setup')\n.reply(200, {allowed: false})\n.persist()\nconst subject = new InfluxDB(url).getSetupApi()\n- const val = await subject.isOnboarded()\n- expect(val)\n- .property('allowed')\n- .equals(false)\n+ const val = await subject.isOnboarding()\n+ expect(val).equals(false)\n})\nit('setup', async () => {\nnock(url)\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat(setup): simplify API, add documentation
305,159
05.01.2020 10:21:12
-3,600
5a645bec50dcac6715069d351744603cdba8d51d
feat: declare UInt8Array as a type of chunk
[ { "change_type": "MODIFY", "old_path": "src/impl/ChunksToLines.ts", "new_path": "src/impl/ChunksToLines.ts", "diff": "@@ -13,7 +13,7 @@ export default class ChunksToLines implements CommunicationObserver<any> {\nprivate chunks: ChunkCombiner\n) {}\n- next(chunk: any): void {\n+ next(chunk: Uint8Array): void {\nif (this.finished) return\ntry {\nthis.bufferReceived(chunk)\n@@ -42,7 +42,7 @@ export default class ChunksToLines implements CommunicationObserver<any> {\nthis.target.useCancellable && this.target.useCancellable(cancellable)\n}\n- private bufferReceived(chunk: any): void {\n+ private bufferReceived(chunk: Uint8Array): void {\nlet index: number\nlet start = 0\nif (this.previous) {\n" }, { "change_type": "MODIFY", "old_path": "src/impl/NodeHttpTransport.ts", "new_path": "src/impl/NodeHttpTransport.ts", "diff": "@@ -112,8 +112,8 @@ export class NodeHttpTransport implements Transport {\nresponseStarted(headers: Headers) {\ncontentType = String(headers['content-type'])\n},\n- next: (data: any): void => {\n- buffer = Buffer.concat([buffer, data as Buffer])\n+ next: (data: Uint8Array): void => {\n+ buffer = Buffer.concat([buffer, data])\n},\ncomplete: (): void => {\ntry {\n" }, { "change_type": "MODIFY", "old_path": "src/transport.ts", "new_path": "src/transport.ts", "diff": "@@ -71,13 +71,13 @@ export interface Transport {\n* @param path HTTP path\n* @param requestBody request body\n* @param options send options\n- * @param callbacks communication callbacks with chunks of any type\n+ * @param callbacks communication callbacks with chunks Uint8Array\n*/\nsend(\npath: string,\nrequestBody: string,\noptions: SendOptions,\n- callbacks?: Partial<CommunicationObserver<any>>\n+ callbacks?: Partial<CommunicationObserver<Uint8Array>>\n): void\n/**\n" }, { "change_type": "MODIFY", "old_path": "test/unit/impl/ChunksToLines.test.ts", "new_path": "test/unit/impl/ChunksToLines.test.ts", "diff": "@@ -53,7 +53,7 @@ describe('ChunksToLines', () => {\nconst target = new CollectLinesObserver()\nconst subject = new ChunksToLines(target, nodeChunkCombiner)\nsubject.next(Buffer.from('abcd', 'utf8'))\n- subject.next(1)\n+ subject.next((1 as any) as Uint8Array)\nexpect(target.failed).to.be.equal(1)\n})\n})\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: declare UInt8Array as a type of chunk
305,159
05.01.2020 23:21:32
-3,600
81aab04435666d0e6ee09907de9587e51dcd8bbd
feat: generate type definitions which are ignored by prettier
[ { "change_type": "ADD", "old_path": null, "new_path": ".prettierignore", "diff": "+**/*.d.ts\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "packages/core/rollup.config.js", "new_path": "packages/core/rollup.config.js", "diff": "@@ -12,7 +12,7 @@ const plugins = [\nsourceMaps(),\ntypescript({\ntypescript: tsc,\n- tsconfigOverride: {\n+ tsconfigDefaults: {\ncompilerOptions: {\ndeclaration: true,\nsourceMap: true,\n" } ]
TypeScript
MIT License
influxdata/influxdb-client-js
feat: generate type definitions which are ignored by prettier