diff --git a/package-lock.json b/package-lock.json index 78e2ab14..ddb4c91a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "node-gitlab-api", - "version": "1.1.4", + "version": "1.2.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -144,12 +144,6 @@ } } }, - "acorn": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.1.tgz", - "integrity": "sha512-vOk6uEMctu0vQrvuSqFdJyqj1Q0S5VTDL79qtjo+DhRr+1mmaD+tluFSCZqhvi/JUhXSzoZN2BhtstaPEeE8cw==", - "dev": true - }, "acorn-jsx": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", @@ -250,6 +244,12 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", + "dev": true + }, "asn1": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", @@ -1022,6 +1022,17 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, + "requires": { + "lru-cache": "4.1.1", + "shebang-command": "1.2.0", + "which": "1.3.0" + } + }, "crypto-random-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", @@ -1118,6 +1129,15 @@ "integrity": "sha512-Vja85njef5T0kGfRUFkyl0etU9+49L1LNKR5oE41wAGRtJR64/a+JX3I8YCIur/uXj4Kt4cNe5i8bfd58ilgKQ==", "dev": true }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "dev": true, + "requires": { + "iconv-lite": "0.4.18" + } + }, "error-ex": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", @@ -1157,31 +1177,33 @@ "dev": true }, "eslint": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.2.0.tgz", - "integrity": "sha1-orMYQRGxmOAunH88ymJaXgHFaz0=", + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.11.0.tgz", + "integrity": "sha512-UWbhQpaKlm8h5x/VLwm0S1kheMrDj8jPwhnBMjr/Dlo3qqT7MvcN/UfKAR3E1N4lr4YNtOvS4m3hwsrVc/ky7g==", "dev": true, "requires": { - "ajv": "5.2.2", + "ajv": "5.5.0", "babel-code-frame": "6.22.0", - "chalk": "1.1.3", + "chalk": "2.3.0", "concat-stream": "1.6.0", - "debug": "2.6.8", + "cross-spawn": "5.1.0", + "debug": "3.1.0", "doctrine": "2.0.0", "eslint-scope": "3.7.1", - "espree": "3.4.3", + "espree": "3.5.2", "esquery": "1.0.0", "estraverse": "4.2.0", "esutils": "2.0.2", "file-entry-cache": "2.0.0", + "functional-red-black-tree": "1.0.1", "glob": "7.1.2", "globals": "9.18.0", "ignore": "3.3.3", "imurmurhash": "0.1.4", "inquirer": "3.2.0", "is-resolvable": "1.0.0", - "js-yaml": "3.9.0", - "json-stable-stringify": "1.0.1", + "js-yaml": "3.10.0", + "json-stable-stringify-without-jsonify": "1.0.1", "levn": "0.3.0", "lodash": "4.17.4", "minimatch": "3.0.4", @@ -1189,24 +1211,111 @@ "natural-compare": "1.4.0", "optionator": "0.8.2", "path-is-inside": "1.0.2", - "pluralize": "4.0.0", + "pluralize": "7.0.0", "progress": "2.0.0", "require-uncached": "1.0.3", + "semver": "5.3.0", + "strip-ansi": "4.0.0", "strip-json-comments": "2.0.1", "table": "4.0.1", "text-table": "0.2.0" }, "dependencies": { + "acorn": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz", + "integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w==", + "dev": true + }, "ajv": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.2.2.tgz", - "integrity": "sha1-R8aNaehvXZUxA7AHSpQw3GPaXjk=", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.0.tgz", + "integrity": "sha1-6yhAdG6dxIvV4GOjbj/UAMXqtak=", "dev": true, "requires": { "co": "4.6.0", "fast-deep-equal": "1.0.0", - "json-schema-traverse": "0.3.1", - "json-stable-stringify": "1.0.1" + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.0" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "espree": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.2.tgz", + "integrity": "sha512-sadKeYwaR/aJ3stC2CdvgXu1T16TdYN+qwCpcWbMnGJ8s0zNWemzrvb2GbD4OhmJ/fwpJjudThAlLobGbWZbCQ==", + "dev": true, + "requires": { + "acorn": "5.2.1", + "acorn-jsx": "3.0.1" + } + }, + "js-yaml": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.10.0.tgz", + "integrity": "sha512-O2v52ffjLa9VeM43J4XocZE//WT9N0IiwDa3KSHH7Tu8CtH+1qM8SIZvnsTh6v+4yFy5KUY3BHUVwjpfAWsjIA==", + "dev": true, + "requires": { + "argparse": "1.0.9", + "esprima": "4.0.0" + } + }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", + "dev": true + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" } } } @@ -1252,9 +1361,9 @@ } }, "eslint-plugin-import": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.7.0.tgz", - "integrity": "sha512-HGYmpU9f/zJaQiKNQOVfHUh2oLWW3STBrCgH0sHTX1xtsxYlH1zjLh8FlQGEIdZSdTbUMaV36WaZ6ImXkenGxQ==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz", + "integrity": "sha512-Rf7dfKJxZ16QuTgVv1OYNxkZcsu/hULFnC+e+w0Gzi6jMC3guQoWQgxYxc54IDRinlb6/0v5z/PxxIKmVctN+g==", "dev": true, "requires": { "builtin-modules": "1.1.1", @@ -1297,14 +1406,26 @@ } }, "eslint-plugin-react": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.1.0.tgz", - "integrity": "sha1-J3cKzzn1/UnNCvQIPOWBBOs5DUw=", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.5.1.tgz", + "integrity": "sha512-YGSjB9Qu6QbVTroUZi66pYky3DfoIPLdHQ/wmrBGyBRnwxQsBXAov9j2rpXt/55i8nyMv6IRWJv2s4d4YnduzQ==", "dev": true, "requires": { "doctrine": "2.0.0", "has": "1.0.1", - "jsx-ast-utils": "1.4.1" + "jsx-ast-utils": "2.0.1", + "prop-types": "15.6.0" + }, + "dependencies": { + "jsx-ast-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", + "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", + "dev": true, + "requires": { + "array-includes": "3.0.3" + } + } } }, "eslint-restricted-globals": { @@ -1323,16 +1444,6 @@ "estraverse": "4.2.0" } }, - "espree": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.4.3.tgz", - "integrity": "sha1-KRC1zNSc6JPC//+qtP2LOjG4I3Q=", - "dev": true, - "requires": { - "acorn": "5.1.1", - "acorn-jsx": "3.0.1" - } - }, "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", @@ -1407,6 +1518,29 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fbjs": { + "version": "0.8.16", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.16.tgz", + "integrity": "sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=", + "dev": true, + "requires": { + "core-js": "1.2.7", + "isomorphic-fetch": "2.2.1", + "loose-envify": "1.3.1", + "object-assign": "4.1.1", + "promise": "7.3.1", + "setimmediate": "1.0.5", + "ua-parser-js": "0.7.17" + }, + "dependencies": { + "core-js": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=", + "dev": true + } + } + }, "figures": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", @@ -1471,6 +1605,12 @@ "integrity": "sha1-FhdnFMgBeY5Ojyz391KUZ7tKV3E=", "dev": true }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -1748,6 +1888,12 @@ "tryit": "1.0.3" } }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true + }, "is-symbol": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", @@ -1765,6 +1911,22 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "dev": true, + "requires": { + "node-fetch": "1.7.3", + "whatwg-fetch": "2.0.3" + } + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -1776,16 +1938,6 @@ "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", "dev": true }, - "js-yaml": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.9.0.tgz", - "integrity": "sha512-0LoUNELX4S+iofCT8f4uEHIiRBR+c2AINyC8qRWfC6QNruLtxVZRJaPcu/xwMgFIgDxF25tGHaDjvxzJCNE9yw==", - "dev": true, - "requires": { - "argparse": "1.0.9", - "esprima": "4.0.0" - } - }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", @@ -1823,6 +1975,12 @@ "jsonify": "0.0.0" } }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -1918,6 +2076,16 @@ "js-tokens": "3.0.2" } }, + "lru-cache": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", + "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", + "dev": true, + "requires": { + "pseudomap": "1.0.2", + "yallist": "2.1.2" + } + }, "mimic-fn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", @@ -1966,6 +2134,16 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "dev": true, + "requires": { + "encoding": "0.1.12", + "is-stream": "1.1.0" + } + }, "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", @@ -2131,12 +2309,6 @@ "find-up": "1.1.2" } }, - "pluralize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-4.0.0.tgz", - "integrity": "sha1-WbcIwcAZCi9pLxx2GMRGsFL9F2I=", - "dev": true - }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -2161,6 +2333,32 @@ "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", "dev": true }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "dev": true, + "requires": { + "asap": "2.0.6" + } + }, + "prop-types": { + "version": "15.6.0", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.6.0.tgz", + "integrity": "sha1-zq8IMCL8RrSjX2nhPvda7Q1jmFY=", + "dev": true, + "requires": { + "fbjs": "0.8.16", + "loose-envify": "1.3.1", + "object-assign": "4.1.1" + } + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", @@ -2537,6 +2735,27 @@ "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true }, + "setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -2761,6 +2980,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "ua-parser-js": { + "version": "0.7.17", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz", + "integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g==", + "dev": true + }, "unique-string": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", @@ -2798,6 +3023,21 @@ "extsprintf": "1.0.2" } }, + "whatwg-fetch": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", + "integrity": "sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=", + "dev": true + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", @@ -2823,6 +3063,12 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true } } } diff --git a/package.json b/package.json index 90631690..87b444a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-gitlab-api", - "version": "1.2.0", + "version": "2.0.0", "description": "Full NodeJS implementation of the GitLab API. Supports Promises, Async/Await.", "main": "src/index.js", "directories": {}, diff --git a/src/API.js b/src/API.js index 9fc82894..399a417a 100644 --- a/src/API.js +++ b/src/API.js @@ -1,7 +1,7 @@ const Request = require('request-promise'); const { Groups, Projects, Issues, Runners, Users, Labels } = require('./Models'); -function defaultRequest(url, endpoint, { headers, body, qs, formData, resolveWithFullResponse = false}) { +function defaultRequest(url, endpoint, { headers, body, qs, formData, resolveWithFullResponse = false }) { const params = { url: `${url}${endpoint}`, headers, diff --git a/src/Models/BaseModel.js b/src/Models/BaseModel.js index 97170f6f..ef3dbc9a 100644 --- a/src/Models/BaseModel.js +++ b/src/Models/BaseModel.js @@ -3,7 +3,7 @@ const LinkParser = require('parse-link-header'); async function getAllPages(client, endpoint, options = {}, results = []) { const response = await client.get(endpoint, options, true); - if(!response.headers['x-page']){ + if (!response.headers['x-page']) { return response; } diff --git a/src/Models/GroupAccessRequests.js b/src/Models/GroupAccessRequests.js index 981dba1f..416df36d 100644 --- a/src/Models/GroupAccessRequests.js +++ b/src/Models/GroupAccessRequests.js @@ -10,10 +10,12 @@ const ACCESS_LEVELS = { }; class GroupAccessRequests extends BaseModel { - constructor(){ - this.ACCESS_LEVELS = ACCESS_LEVELS; + constructor(...args) { + super(...args); + + this.ACCESS_LEVELS = ACCESS_LEVELS; } - + all(groupId) { const gId = Utils.parse(groupId); @@ -26,10 +28,10 @@ class GroupAccessRequests extends BaseModel { return this.post(`groups/${gId}/access_requests`); } - approve(groupId, userId, {access_level = 30}) { + approve(groupId, userId, { access_level = 30 }) { const [gId, uId] = [groupId, userId].map(Utils.parse); - return this.post(`groups/${gId}/access_requests/${uId}/approve`, {access_level}); + return this.post(`groups/${gId}/access_requests/${uId}/approve`, { access_level }); } deny(groupId, userId) { diff --git a/src/Models/GroupMilestoneIssues.js b/src/Models/GroupMilestoneIssues.js index f60e1440..59f4d06a 100644 --- a/src/Models/GroupMilestoneIssues.js +++ b/src/Models/GroupMilestoneIssues.js @@ -2,7 +2,7 @@ const BaseModel = require('./BaseModel'); const Utils = require('../Utils'); class GroupMilestoneIssues extends BaseModel { - all(grougId, milestoneId) { + all(groupId, milestoneId) { const [gId, mId] = [groupId, milestoneId].map(Utils.parse); return this.get(`groups/${gId}/milestones/${mId}/issues`); diff --git a/src/Models/GroupMilestoneMergeRequests.js b/src/Models/GroupMilestoneMergeRequests.js index 2e811a45..122cdd6f 100644 --- a/src/Models/GroupMilestoneMergeRequests.js +++ b/src/Models/GroupMilestoneMergeRequests.js @@ -2,11 +2,11 @@ const BaseModel = require('./BaseModel'); const Utils = require('../Utils'); class GroupMilestoneMergeRequests extends BaseModel { - all(grougId, milestoneId) { + all(groupId, milestoneId) { const [gId, mId] = [groupId, milestoneId].map(Utils.parse); - return this.get(`groups/${pId}/milestones/${mId}/merge_requests`); + return this.get(`groups/${gId}/milestones/${mId}/merge_requests`); } } -module.exports = GroupMilestoneIssues; +module.exports = GroupMilestoneMergeRequests; diff --git a/src/Models/GroupMilestones.js b/src/Models/GroupMilestones.js index 2c02e153..72535287 100644 --- a/src/Models/GroupMilestones.js +++ b/src/Models/GroupMilestones.js @@ -1,45 +1,39 @@ const BaseModel = require('./BaseModel'); +const GroupMilestoneIssues = require('./GroupMilestoneIssues'); +const GroupMilestoneMergeRequests = require('./GroupMilestoneMergeRequests'); + const Utils = require('../Utils'); class GroupMilestones extends BaseModel { - constructor(..args){ - this.issues = new GroupMilestoneIssues(..args); - this.mergeRequests = new GroupMilestoneMergeRequests(..args); + constructor(...args) { + super(...args); + + this.issues = new GroupMilestoneIssues(...args); + this.mergeRequests = new GroupMilestoneMergeRequests(...args); } all(groupId, options = {}) { - const pId = Utils.parse(groupId); + const gId = Utils.parse(groupId); - return this.get(`groups/${pId}/milestones`, options); + return this.get(`groups/${gId}/milestones`, options); } show(groupId, milestoneId) { - const [pId, mId] = [groupId, milestoneId].map(Utils.parse); + const [gId, mId] = [groupId, milestoneId].map(Utils.parse); - return this.get(`groups/${pId}/milestones/${mId}`); + return this.get(`groups/${gId}/milestones/${mId}`); } - create(groupId, title, { description, due_date, start_date }) { - const pId = Utils.parse(groupId); + create(groupId, title, options) { + const gId = Utils.parse(groupId); - return this.post(`groups/${pId}/milestones`, { - title, - description, - due_date, - start_date, - }); + return this.post(`groups/${gId}/milestones`, options); } - update(groupId, milestoneId, { title, description, due_date, start_date, state_event }) { - const [pId, mId] = [projectId, milestoneId].map(Utils.parse); + update(groupId, milestoneId, options) { + const [gId, mId] = [groupId, milestoneId].map(Utils.parse); - return this.put(`groups/${pId}/milestones/${mId}`, { - title, - description, - due_date, - start_date, - state_event, - }); + return this.put(`groups/${gId}/milestones/${mId}`, options); } } diff --git a/src/Models/Groups.js b/src/Models/Groups.js index 4cc7a5e8..9d649b58 100644 --- a/src/Models/Groups.js +++ b/src/Models/Groups.js @@ -1,4 +1,8 @@ const BaseModel = require('./BaseModel'); +const GroupMilestones = require('./GroupMilestones'); +const GroupMembers = require('./GroupMembers'); +const GroupProjects = require('./GroupProjects'); +const GroupAccessRequests = require('./GroupAccessRequests'); const Utils = require('../Utils'); class Groups extends BaseModel { @@ -8,7 +12,7 @@ class Groups extends BaseModel { this.milestones = new GroupMilestones(...args); this.members = new GroupMembers(...args); this.projects = new GroupProjects(...args); - this.accessLevels = new GroupAccessLevels(...args); + this.accessRequests = new GroupAccessRequests(...args); } all(options = {}) { diff --git a/src/Models/Issues.js b/src/Models/Issues.js index 0bfc4c88..16de3077 100644 --- a/src/Models/Issues.js +++ b/src/Models/Issues.js @@ -1,5 +1,4 @@ const BaseModel = require('./BaseModel'); -const Utils = require('../Utils'); class Issues extends BaseModel { all(options = {}) { diff --git a/src/Models/Labels.js b/src/Models/Labels.js index d705da5d..583537a8 100644 --- a/src/Models/Labels.js +++ b/src/Models/Labels.js @@ -17,9 +17,7 @@ class Labels extends BaseModel { edit(projectId, labelName, options = {}) { const pId = Utils.parse(projectId); - options.name = labelName; - - return this.put(`projects/${pId}/labels`, options); + return this.put(`projects/${pId}/labels`, Object.assign({ name: labelName }, options)); } remove(projectId, labelName) { diff --git a/src/Models/ProjectAccessRequests.js b/src/Models/ProjectAccessRequests.js index d89bbfdc..2faa2201 100644 --- a/src/Models/ProjectAccessRequests.js +++ b/src/Models/ProjectAccessRequests.js @@ -10,10 +10,12 @@ const ACCESS_LEVELS = { }; class ProjectAccessRequests extends BaseModel { - constructor(){ - this.ACCESS_LEVELS = ACCESS_LEVELS; + constructor(...args) { + super(...args); + + this.ACCESS_LEVELS = ACCESS_LEVELS; } - + all(projectId) { const pId = Utils.parse(projectId); @@ -26,10 +28,10 @@ class ProjectAccessRequests extends BaseModel { return this.post(`projects/${pId}/access_requests`); } - approve(projectId, userId, {access_level = 30}) { + approve(projectId, userId, { access_level = 30 }) { const [pId, uId] = [projectId, userId].map(Utils.parse); - return this.post(`projects/${pId}/access_requests/${uId}/approve`, {access_level}); + return this.post(`projects/${pId}/access_requests/${uId}/approve`, { access_level }); } deny(projectId, userId) { diff --git a/src/Models/ProjectDeployKeys.js b/src/Models/ProjectDeployKeys.js index e5e26f1e..dc2e26f6 100644 --- a/src/Models/ProjectDeployKeys.js +++ b/src/Models/ProjectDeployKeys.js @@ -21,4 +21,4 @@ class ProjectDeployKeys extends BaseModel { } } -module.exports = ProjectDeployKeys; +module.exports = ProjectDeployKeys; \ No newline at end of file diff --git a/src/Models/ProjectHooks.js b/src/Models/ProjectHooks.js index d68e4f36..58802014 100644 --- a/src/Models/ProjectHooks.js +++ b/src/Models/ProjectHooks.js @@ -15,17 +15,15 @@ class ProjectHooks extends BaseModel { } add(projectId, url, options = {}) { - options.url = url; const pId = Utils.parse(projectId); - return this.post(`projects/${pId}/hooks`, options); + return this.post(`projects/${pId}/hooks`, Object.assign({ url }, options)); } - edit(projectId, hookId, url, options) { - options.url = url; + edit(projectId, hookId, url, options = {}) { const [pId, hId] = [projectId, hookId].map(Utils.parse); - return this.put(`projects/${pId}/hooks/${hId}`, options); + return this.put(`projects/${pId}/hooks/${hId}`, Object.assign({ url }, options)); } remove(projectId, hookId) { diff --git a/src/Models/ProjectIssues.js b/src/Models/ProjectIssues.js index 492f8ff6..fdc85d58 100644 --- a/src/Models/ProjectIssues.js +++ b/src/Models/ProjectIssues.js @@ -27,6 +27,13 @@ class ProjectIssues extends BaseModel { return this.put(`projects/${pId}/issues/${iId}`, options); } + link(projectId, issueIId, targetProjectId, targetIssueId, options = {}) { + const [pId, iId] = [projectId, issueIId].map(Utils.parse); + const [targetpId, targetIId] = [targetProjectId, targetIssueId].map(Utils.parse); + + return this.post(`projects/${pId}/issues/${iId}/links`, Object.assign({ target_project_id: targetpId, target_issue_id: targetIId }, options)); + } + remove(projectId, issueId) { const [pId, iId] = [projectId, issueId].map(Utils.parse); @@ -50,15 +57,6 @@ class ProjectIssues extends BaseModel { return this.delete(`projects/${pId}/issues/${iId}/unsubscribe`); } - - link(projectId, issueIId, targetProjectId, targetIssueId, options = {}) { - const [pId, iId] = [projectId, issueIId].map(Utils.parse); - const [targetpId, targetIId] = [targetProjectId, targetIssueId].map(Utils.parse); - options.target_project_id = targetpId; - options.target_issue_id = targetIId; - - return this.post(`projects/${pId}/issues/${iId}/links`, options); - } } module.exports = ProjectIssues; diff --git a/src/Models/ProjectMembers.js b/src/Models/ProjectMembers.js index 2c5a05d8..58fa4f7c 100644 --- a/src/Models/ProjectMembers.js +++ b/src/Models/ProjectMembers.js @@ -2,18 +2,12 @@ const BaseModel = require('./BaseModel'); const Utils = require('../Utils'); class ProjectMembers extends BaseModel { - list(projectId) { + all(projectId) { const pId = Utils.parse(projectId); return this.get(`projects/${pId}/members`); } - show(projectId, userId) { - const [pId, uId] = [projectId, userId].map(Utils.parse); - - return this.get(`projects/${pId}/members/${uId}`); - } - add(projectId, userId, accessLevel = 30) { const [pId, uId] = [projectId, userId].map(Utils.parse); @@ -36,6 +30,12 @@ class ProjectMembers extends BaseModel { return this.delete(`projects/${pId}/members/${uId}`); } + + show(projectId, userId) { + const [pId, uId] = [projectId, userId].map(Utils.parse); + + return this.get(`projects/${pId}/members/${uId}`); + } } module.exports = ProjectMembers; diff --git a/src/Models/ProjectMergeRequests.js b/src/Models/ProjectMergeRequests.js index f7d1bfed..23214129 100644 --- a/src/Models/ProjectMergeRequests.js +++ b/src/Models/ProjectMergeRequests.js @@ -2,21 +2,8 @@ const BaseModel = require('./BaseModel'); const Utils = require('../Utils'); class ProjectMergeRequests extends BaseModel { - list(projectId, options = {}) { - const pId = Utils.parse(projectId); - - return this.get(`projects/${pId}/merge_requests`, options); - } - - show(projectId, mergerequestId) { - const [pId, mId] = [projectId, mergerequestId].map(Utils.parse); - - return this.get(`projects/${pId}/merge_requests/${mId}`); - } - add(projectId, sourceBranch, targetBranch, assigneeId, title) { const [pId, aId] = [projectId, assigneeId].map(Utils.parse); - const options = { id: pId, source_branch: sourceBranch, @@ -29,13 +16,10 @@ class ProjectMergeRequests extends BaseModel { return this.post(`projects/${pId}/merge_requests`, options); } - update(projectId, mergerequestId, options = {}) { - const [pId, mId] = [projectId, mergerequestId].map(Utils.parse); + all(projectId, options = {}) { + const pId = Utils.parse(projectId); - options.id = pId; - options.merge_request_id = mId; - - return this.put(`projects/${pId}/merge_requests/${mId}`, options); + return this.get(`projects/${pId}/merge_requests`, options); } comment(projectId, mergerequestId, note) { @@ -45,6 +29,18 @@ class ProjectMergeRequests extends BaseModel { body: note, }); } + + show(projectId, mergerequestId) { + const [pId, mId] = [projectId, mergerequestId].map(Utils.parse); + + return this.get(`projects/${pId}/merge_requests/${mId}`); + } + + update(projectId, mergerequestId, options = {}) { + const [pId, mId] = [projectId, mergerequestId].map(Utils.parse); + + return this.put(`projects/${pId}/merge_requests/${mId}`, options); + } } module.exports = ProjectMergeRequests; diff --git a/src/Models/ProjectMilestones.js b/src/Models/ProjectMilestones.js index 1f09567b..be5ccd56 100644 --- a/src/Models/ProjectMilestones.js +++ b/src/Models/ProjectMilestones.js @@ -14,25 +14,16 @@ class ProjectMilestones extends BaseModel { return this.get(`projects/${pId}/milestones/${mId}`); } - add(projectId, title, { description, due_date }) { + add(projectId, title, options) { const pId = Utils.parse(projectId); - return this.post(`projects/${pId}/milestones`, { - title, - description, - due_date, - }); + return this.post(`projects/${pId}/milestones`, options); } - update(projectId, milestoneId, { title, description, due_date, state_event }) { + update(projectId, milestoneId, options) { const [pId, mId] = [projectId, milestoneId].map(Utils.parse); - return this.put(`projects/${pId}/milestones/${mId}`, { - title, - description, - due_date, - state_event, - }); + return this.put(`projects/${pId}/milestones/${mId}`, options); } } diff --git a/src/Models/ProjectRepository.js b/src/Models/ProjectRepository.js index dbdaa141..05eaed51 100644 --- a/src/Models/ProjectRepository.js +++ b/src/Models/ProjectRepository.js @@ -1,12 +1,18 @@ const BaseModel = require('./BaseModel'); +const ProjectRepositoryBranches = require('./ProjectRepositoryBranches'); +const ProjectRepositoryTags = require('./ProjectRepositoryTags'); +const ProjectRepositoryCommits = require('./ProjectRepositoryCommits'); +const ProjectRepositoryFiles = require('./ProjectRepositoryFiles'); const Utils = require('../Utils'); class ProjectRepository extends BaseModel { - constructor() { - this.branches = new ProjectRepositoryBranches(..args); - this.tags = new ProjectRepositoryTags(..args); - this.commits = new ProjectRepositoryCommits(..args); - this.files = new ProjectRepositoryFiles(..args); + constructor(...args) { + super(...args); + + this.branches = new ProjectRepositoryBranches(...args); + this.tags = new ProjectRepositoryTags(...args); + this.commits = new ProjectRepositoryCommits(...args); + this.files = new ProjectRepositoryFiles(...args); } compare(projectId, from, to) { @@ -46,4 +52,4 @@ class ProjectRepository extends BaseModel { } } -module.exports = ProjectRepository; \ No newline at end of file +module.exports = ProjectRepository; diff --git a/src/Models/ProjectRepositoryBranches.js b/src/Models/ProjectRepositoryBranches.js index 1524293f..28a2648c 100644 --- a/src/Models/ProjectRepositoryBranches.js +++ b/src/Models/ProjectRepositoryBranches.js @@ -29,7 +29,7 @@ class ProjectRepositoryBranches extends BaseModel { show(projectId, branchName) { const pId = Utils.parse(projectId); - return this.get(`projects/${pId}/repository/branches/${encodeURI(branchId)}`); + return this.get(`projects/${pId}/repository/branches/${encodeURI(branchName)}`); } unprotect(projectId, branchName) { @@ -39,4 +39,4 @@ class ProjectRepositoryBranches extends BaseModel { } } -module.exports = ProjectRepositoryBranches; +module.exports = ProjectRepositoryBranches; \ No newline at end of file diff --git a/src/Models/ProjectRepositoryFiles.js b/src/Models/ProjectRepositoryFiles.js index e05829a8..3985714a 100644 --- a/src/Models/ProjectRepositoryFiles.js +++ b/src/Models/ProjectRepositoryFiles.js @@ -17,13 +17,13 @@ class ProjectRepositoryFiles extends BaseModel { show(projectId, filePath, ref) { const pId = Utils.parse(projectId); - return this.get(`projects/${pId}/repository/files/${filePath}`, { ref: options.ref }); + return this.get(`projects/${pId}/repository/files/${filePath}`, { ref }); } showRaw(projectId, filePath, ref) { const pId = Utils.parse(projectId); - return this.get(`projects/${pId}/repository/files/${filePath}/raw`, { ref: options.ref }); + return this.get(`projects/${pId}/repository/files/${filePath}/raw`, { ref }); } update(projectId, filePath, branch, options = {}) { diff --git a/src/Models/ProjectRunners.js b/src/Models/ProjectRunners.js index fafcd700..f0b3688e 100644 --- a/src/Models/ProjectRunners.js +++ b/src/Models/ProjectRunners.js @@ -5,11 +5,7 @@ class ProjectRunners extends BaseModel { all(projectId, options = {}) { const pId = Utils.parse(projectId); - if (projectId != null) { - return this.get(`projects/${pId}/runners`, options); - } - - return this.get('runners', options); + return this.get(`projects/${pId}/runners`, options); } enable(projectId, runnerId) { @@ -25,7 +21,6 @@ class ProjectRunners extends BaseModel { return this.delete(`projects/${pId}/runners/${rId}`); } - } module.exports = ProjectRunners; diff --git a/src/Models/ProjectTriggers.js b/src/Models/ProjectTriggers.js index 7ed26223..cbb68968 100644 --- a/src/Models/ProjectTriggers.js +++ b/src/Models/ProjectTriggers.js @@ -8,18 +8,18 @@ class ProjectTriggers extends BaseModel { return this.post(`projects/${pId}/triggers`, options); } + all(projectId) { + const pId = Utils.parse(projectId); + + return this.get(`projects/${pId}/triggers`); + } + edit(projectId, triggerId, options = {}) { const [pId, tId] = [projectId, triggerId].map(Utils.parse); return this.put(`projects/${pId}/triggers/${tId}`, options); } - list(projectId) { - const pId = Utils.parse(projectId); - - return this.get(`projects/${pId}/triggers`); - } - remove(projectId, triggerId) { const [pId, tId] = [projectId, triggerId].map(Utils.parse); diff --git a/src/Models/Runners.js b/src/Models/Runners.js index a4a0cd5f..d2379f4a 100644 --- a/src/Models/Runners.js +++ b/src/Models/Runners.js @@ -6,6 +6,12 @@ class Runners extends BaseModel { return this.get('runners/all', options); } + remove(runnerId) { + const rId = Utils.parse(runnerId); + + return this.delete(`runners/${rId}`); + } + show(runnerId) { const rId = Utils.parse(runnerId); @@ -17,12 +23,6 @@ class Runners extends BaseModel { return this.put(`runners/${rId}`, attributes); } - - remove(runnerId) { - const rId = Utils.parse(runnerId); - - return this.delete(`runners/${rId}`); - } } module.exports = Runners; diff --git a/src/Models/Users.js b/src/Models/Users.js index b4548861..b49a8e94 100644 --- a/src/Models/Users.js +++ b/src/Models/Users.js @@ -13,20 +13,14 @@ class Users extends BaseModel { return this.get('users', options); } - current() { - return this.get('user'); - } - - show(userId) { - const uId = Utils.parse(userId); - - return this.get(`users/${uId}`); - } - create(options = {}) { return this.post('users', options); } + current() { + return this.get('user'); + } + session(email, password) { return this.post('session', { email, @@ -39,6 +33,12 @@ class Users extends BaseModel { search: emailOrUsername, }); } + + show(userId) { + const uId = Utils.parse(userId); + + return this.get(`users/${uId}`); + } } module.exports = Users; diff --git a/src/Models/index.js b/src/Models/index.js index e5ce643b..6b5e1053 100644 --- a/src/Models/index.js +++ b/src/Models/index.js @@ -5,4 +5,4 @@ const Users = require('./Users'); const Labels = require('./Labels'); const Runners = require('./Runners'); -module.exports = { Groups, Projects, Runners, Issues, Users, Labels }; +module.exports = { Groups, Projects, Runners, Issues, Users, Labels }; \ No newline at end of file