refactor: move to eslint

This commit is contained in:
Rainer Killinger
2022-07-04 15:02:09 +02:00
parent 3e2c7a1927
commit bb45c36d86
16 changed files with 632 additions and 251 deletions

2
.eslintignore Normal file
View File

@@ -0,0 +1,2 @@
resources
openapi

3
.eslintrc.json Normal file
View File

@@ -0,0 +1,3 @@
{
"extends": "@openstapps"
}

520
package-lock.json generated
View File

@@ -310,6 +310,17 @@
"@jridgewell/trace-mapping": "0.3.9" "@jridgewell/trace-mapping": "0.3.9"
} }
}, },
"@es-joy/jsdoccomment": {
"version": "0.31.0",
"resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.31.0.tgz",
"integrity": "sha512-tc1/iuQcnaiSIUVad72PBierDFpsxdUHtEF/OrfqvM1CBAsIoMP51j52jTMb3dXriwhieTo289InzZj72jL3EQ==",
"dev": true,
"requires": {
"comment-parser": "1.3.1",
"esquery": "^1.4.0",
"jsdoc-type-pratt-parser": "~3.1.0"
}
},
"@eslint/eslintrc": { "@eslint/eslintrc": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz",
@@ -516,19 +527,17 @@
} }
}, },
"@openstapps/configuration": { "@openstapps/configuration": {
"version": "0.29.1", "version": "0.32.0",
"resolved": "https://registry.npmjs.org/@openstapps/configuration/-/configuration-0.29.1.tgz", "resolved": "https://registry.npmjs.org/@openstapps/configuration/-/configuration-0.32.0.tgz",
"integrity": "sha512-H6DNB1HrujC5LwOF17rYkXQPFaEWTaA5T3IPsfccSuKHSUhB0ry6V5OkMwmvls2nOSrbpuRpyQoM7ulwZ9X9Bw==", "integrity": "sha512-tvM2xsdBoBNlsz3R6veldI45mrGbBhq9sBA+E5DI7mSHC8kP42PJvZ5t24vM3ze6LIcLXSeB5n3LhxIFHgpuHA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": "14.18.18", "@types/node": "14.18.18",
"@types/semver": "7.3.9", "@types/semver": "7.3.9",
"@types/yaml": "1.9.7", "@types/yaml": "1.9.7",
"chalk": "4.1.2", "chalk": "4.1.2",
"commander": "9.2.0", "commander": "9.3.0",
"semver": "7.3.7", "semver": "7.3.7",
"tslint": "6.1.3",
"tslint-eslint-rules": "5.4.0",
"yaml": "1.10.2" "yaml": "1.10.2"
}, },
"dependencies": { "dependencies": {
@@ -537,12 +546,6 @@
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.18.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.18.tgz",
"integrity": "sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==", "integrity": "sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==",
"dev": true "dev": true
},
"commander": {
"version": "9.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.2.0.tgz",
"integrity": "sha512-e2i4wANQiSXgnrBlIatyHtP1odfUp0BbV5Y5nEGbxtIrStkEOAAzCUirvLBNXHLr7kwLvJl6V+4V3XV9x7Wd9w==",
"dev": true
} }
} }
}, },
@@ -594,6 +597,79 @@
"typescript": "4.4.4" "typescript": "4.4.4"
}, },
"dependencies": { "dependencies": {
"escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="
},
"eslint": {
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.18.0.tgz",
"integrity": "sha512-As1EfFMVk7Xc6/CvhssHUjsAQSkpfXvUGMFC3ce8JDe6WvqCgRrLOBQbVpsBFr1X1V+RACOadnzVvcUS5ni2bA==",
"requires": {
"@eslint/eslintrc": "^1.3.0",
"@humanwhocodes/config-array": "^0.9.2",
"ajv": "^6.10.0",
"chalk": "^4.0.0",
"cross-spawn": "^7.0.2",
"debug": "^4.3.2",
"doctrine": "^3.0.0",
"escape-string-regexp": "^4.0.0",
"eslint-scope": "^7.1.1",
"eslint-utils": "^3.0.0",
"eslint-visitor-keys": "^3.3.0",
"espree": "^9.3.2",
"esquery": "^1.4.0",
"esutils": "^2.0.2",
"fast-deep-equal": "^3.1.3",
"file-entry-cache": "^6.0.1",
"functional-red-black-tree": "^1.0.1",
"glob-parent": "^6.0.1",
"globals": "^13.15.0",
"ignore": "^5.2.0",
"import-fresh": "^3.0.0",
"imurmurhash": "^0.1.4",
"is-glob": "^4.0.0",
"js-yaml": "^4.1.0",
"json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1",
"lodash.merge": "^4.6.2",
"minimatch": "^3.1.2",
"natural-compare": "^1.4.0",
"optionator": "^0.9.1",
"regexpp": "^3.2.0",
"strip-ansi": "^6.0.1",
"strip-json-comments": "^3.1.0",
"text-table": "^0.2.0",
"v8-compile-cache": "^2.0.3"
},
"dependencies": {
"ajv": {
"version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"requires": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
"json-schema-traverse": "^0.4.1",
"uri-js": "^4.2.2"
}
}
}
},
"glob-parent": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
"integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",
"requires": {
"is-glob": "^4.0.3"
}
},
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
},
"ts-node": { "ts-node": {
"version": "10.8.1", "version": "10.8.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.8.1.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.8.1.tgz",
@@ -613,14 +689,15 @@
"v8-compile-cache-lib": "^3.0.1", "v8-compile-cache-lib": "^3.0.1",
"yn": "3.1.1" "yn": "3.1.1"
} }
},
"typescript": {
"version": "4.4.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz",
"integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA=="
} }
} }
}, },
"@openstapps/eslint-config": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@openstapps/eslint-config/-/eslint-config-1.1.0.tgz",
"integrity": "sha512-yhSWgzKB5cU3kTtWdAOEO6y4PjLDBnyJc+Dpmz9Rxg97WSViOiz3Bv9BWTSl0TR56GAnFi0NI8K56RfCqjpk5w==",
"dev": true
},
"@openstapps/logger": { "@openstapps/logger": {
"version": "0.8.1", "version": "0.8.1",
"resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-0.8.1.tgz", "resolved": "https://registry.npmjs.org/@openstapps/logger/-/logger-0.8.1.tgz",
@@ -939,6 +1016,119 @@
"yaml": "*" "yaml": "*"
} }
}, },
"@typescript-eslint/eslint-plugin": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.4.tgz",
"integrity": "sha512-xjujQISAIa4HAaos8fcMZXmqkuZqMx6icdxkI88jMM/eNe4J8AuTLYnLK+zdm0mBYLyctdFf//UE4/xFCcQzYQ==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.30.4",
"@typescript-eslint/type-utils": "5.30.4",
"@typescript-eslint/utils": "5.30.4",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.2.0",
"regexpp": "^3.2.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/parser": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.30.4.tgz",
"integrity": "sha512-/ge1HtU63wVoED4VnlU2o+FPFmi017bPYpeSrCmd8Ycsti4VSxXrmcpXXm7JpI4GT0Aa7qviabv1PEp6L5bboQ==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.30.4",
"@typescript-eslint/types": "5.30.4",
"@typescript-eslint/typescript-estree": "5.30.4",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.30.4.tgz",
"integrity": "sha512-DNzlQwGSiGefz71JwaHrpcaAX3zYkEcy8uVuan3YMKOa6qeW/y+7SaD8KIsIAruASwq6P+U4BjWBWtM2O+mwBQ==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.30.4",
"@typescript-eslint/visitor-keys": "5.30.4"
}
},
"@typescript-eslint/type-utils": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.30.4.tgz",
"integrity": "sha512-55cf1dZviwwv+unDB+mF8vZkfta5muTK6bppPvenWWCD7slZZ0DEsXUjZerqy7Rq8s3J4SXdg4rMIY8ngCtTmA==",
"dev": true,
"requires": {
"@typescript-eslint/utils": "5.30.4",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/types": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.30.4.tgz",
"integrity": "sha512-NTEvqc+Vvu8Q6JeAKryHk2eqLKqsr2St3xhIjhOjQv5wQUBhaTuix4WOSacqj0ONWfKVU12Eug3LEAB95GBkMA==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.30.4.tgz",
"integrity": "sha512-V4VnEs6/J9/nNizaA12IeU4SAeEYaiKr7XndLNfV5+3zZSB4hIu6EhHJixTKhvIqA+EEHgBl6re8pivBMLLO1w==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.30.4",
"@typescript-eslint/visitor-keys": "5.30.4",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/utils": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.30.4.tgz",
"integrity": "sha512-a+GQrJzOUhn4WT1mUumXDyam+22Oo4c5K/jnZ+6r/4WTQF3q8e4CsC9PLHb4SnOClzOqo/5GLZWvkE1aa5UGKQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.30.4",
"@typescript-eslint/types": "5.30.4",
"@typescript-eslint/typescript-estree": "5.30.4",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
},
"dependencies": {
"eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
"integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
"dev": true,
"requires": {
"esrecurse": "^4.3.0",
"estraverse": "^4.1.1"
}
},
"estraverse": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
"dev": true
}
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.30.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.30.4.tgz",
"integrity": "sha512-ulKGse3mruSc8x6l8ORSc6+1ORyJzKmZeIaRTu/WpaF/jx3vHvEn5XZUKF9XaVg2710mFmTAUlLcLYLPp/Zf/Q==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.30.4",
"eslint-visitor-keys": "^3.3.0"
}
},
"@ungap/promise-all-settled": { "@ungap/promise-all-settled": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz",
@@ -1252,9 +1442,9 @@
} }
}, },
"builtin-modules": { "builtin-modules": {
"version": "1.1.1", "version": "3.3.0",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",
"integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==", "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",
"dev": true "dev": true
}, },
"bytes": { "bytes": {
@@ -1427,6 +1617,21 @@
"resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz",
"integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ=="
}, },
"ci-info": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.3.2.tgz",
"integrity": "sha512-xmDt/QIAdeZ9+nfdPsaBCpMvHNLFiLdjj59qjqn+6iPe6YmHGQ35sBnQ8uslRBXFmXkiZQOJRjvQeoGppoTjjg==",
"dev": true
},
"clean-regexp": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz",
"integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==",
"dev": true,
"requires": {
"escape-string-regexp": "^1.0.5"
}
},
"clean-stack": { "clean-stack": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
@@ -1482,6 +1687,12 @@
"resolved": "https://registry.npmjs.org/commander/-/commander-9.3.0.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-9.3.0.tgz",
"integrity": "sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw==" "integrity": "sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw=="
}, },
"comment-parser": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.3.1.tgz",
"integrity": "sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA==",
"dev": true
},
"commondir": { "commondir": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz",
@@ -2016,9 +2227,10 @@
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==" "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg=="
}, },
"eslint": { "eslint": {
"version": "8.18.0", "version": "8.19.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.18.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.19.0.tgz",
"integrity": "sha512-As1EfFMVk7Xc6/CvhssHUjsAQSkpfXvUGMFC3ce8JDe6WvqCgRrLOBQbVpsBFr1X1V+RACOadnzVvcUS5ni2bA==", "integrity": "sha512-SXOPj3x9VKvPe81TjjUJCYlV4oJjQw68Uek+AM0X4p+33dj2HY5bpTZOgnQHcG2eAm1mtCU9uNMnJi7exU/kYw==",
"dev": true,
"requires": { "requires": {
"@eslint/eslintrc": "^1.3.0", "@eslint/eslintrc": "^1.3.0",
"@humanwhocodes/config-array": "^0.9.2", "@humanwhocodes/config-array": "^0.9.2",
@@ -2061,6 +2273,7 @@
"version": "6.12.6", "version": "6.12.6",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
"integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
"dev": true,
"requires": { "requires": {
"fast-deep-equal": "^3.1.1", "fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0", "fast-json-stable-stringify": "^2.0.0",
@@ -2071,12 +2284,14 @@
"escape-string-regexp": { "escape-string-regexp": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true
}, },
"glob-parent": { "glob-parent": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
"integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==",
"dev": true,
"requires": { "requires": {
"is-glob": "^4.0.3" "is-glob": "^4.0.3"
} }
@@ -2084,7 +2299,133 @@
"json-schema-traverse": { "json-schema-traverse": {
"version": "0.4.1", "version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"dev": true
}
}
},
"eslint-config-prettier": {
"version": "8.5.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz",
"integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==",
"dev": true
},
"eslint-plugin-jsdoc": {
"version": "39.3.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.3.3.tgz",
"integrity": "sha512-K/DAjKRUNaUTf0KQhI9PvsF+Y3mGDx/j0pofXsJCQe/tmRsRweBIXR353c8nAro0lytZYEf7l0PluBpzKDiHxw==",
"dev": true,
"requires": {
"@es-joy/jsdoccomment": "~0.31.0",
"comment-parser": "1.3.1",
"debug": "^4.3.4",
"escape-string-regexp": "^4.0.0",
"esquery": "^1.4.0",
"semver": "^7.3.7",
"spdx-expression-parse": "^3.0.1"
},
"dependencies": {
"escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true
}
}
},
"eslint-plugin-prettier": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz",
"integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==",
"dev": true,
"requires": {
"prettier-linter-helpers": "^1.0.0"
}
},
"eslint-plugin-unicorn": {
"version": "43.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-43.0.0.tgz",
"integrity": "sha512-Z/6HX8yry+zAjo4jHHTAbe1rfniox7qgmCReGBfTc/CVgotfScaMCc4dtSSTHlJ+7Yix5o6LPXzwwpuGGFricg==",
"dev": true,
"requires": {
"@babel/helper-validator-identifier": "^7.18.6",
"ci-info": "^3.3.2",
"clean-regexp": "^1.0.0",
"eslint-utils": "^3.0.0",
"esquery": "^1.4.0",
"indent-string": "^4.0.0",
"is-builtin-module": "^3.1.0",
"lodash": "^4.17.21",
"pluralize": "^8.0.0",
"read-pkg-up": "^7.0.1",
"regexp-tree": "^0.1.24",
"safe-regex": "^2.1.1",
"semver": "^7.3.7",
"strip-indent": "^3.0.0"
},
"dependencies": {
"hosted-git-info": {
"version": "2.8.9",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
"integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
"normalize-package-data": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
"integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==",
"dev": true,
"requires": {
"hosted-git-info": "^2.1.4",
"resolve": "^1.10.0",
"semver": "2 || 3 || 4 || 5",
"validate-npm-package-license": "^3.0.1"
},
"dependencies": {
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
}
}
},
"read-pkg": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz",
"integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==",
"dev": true,
"requires": {
"@types/normalize-package-data": "^2.4.0",
"normalize-package-data": "^2.5.0",
"parse-json": "^5.0.0",
"type-fest": "^0.6.0"
},
"dependencies": {
"type-fest": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz",
"integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==",
"dev": true
}
}
},
"read-pkg-up": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz",
"integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==",
"dev": true,
"requires": {
"find-up": "^4.1.0",
"read-pkg": "^5.2.0",
"type-fest": "^0.8.1"
}
},
"type-fest": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz",
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true
} }
} }
}, },
@@ -2227,6 +2568,12 @@
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
}, },
"fast-diff": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"fast-glob": { "fast-glob": {
"version": "3.2.11", "version": "3.2.11",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz",
@@ -2474,12 +2821,6 @@
"yargs": "^16.2.0" "yargs": "^16.2.0"
}, },
"dependencies": { "dependencies": {
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"dev": true
},
"readable-stream": { "readable-stream": {
"version": "2.3.7", "version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
@@ -2915,6 +3256,15 @@
"binary-extensions": "^2.0.0" "binary-extensions": "^2.0.0"
} }
}, },
"is-builtin-module": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.1.0.tgz",
"integrity": "sha512-OV7JjAgOTfAFJmHZLvpSTb4qi0nIILDV1gWPYDnDJUTNFM5aGlRAhk4QcT8i7TuAleeEV5Fdkqn3t4mS+Q11fg==",
"dev": true,
"requires": {
"builtin-modules": "^3.0.0"
}
},
"is-core-module": { "is-core-module": {
"version": "2.9.0", "version": "2.9.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.9.0.tgz",
@@ -3008,9 +3358,9 @@
"dev": true "dev": true
}, },
"isarray": { "isarray": {
"version": "0.0.1", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
"dev": true "dev": true
}, },
"isexe": { "isexe": {
@@ -3135,6 +3485,12 @@
"argparse": "^2.0.1" "argparse": "^2.0.1"
} }
}, },
"jsdoc-type-pratt-parser": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-3.1.0.tgz",
"integrity": "sha512-MgtD0ZiCDk9B+eI73BextfRrVQl0oyzRG8B2BjORts6jbunj4ScKPcyXGTbB6eXL4y9TzxCm6hyeLq/2ASzNdw==",
"dev": true
},
"jsesc": { "jsesc": {
"version": "2.5.2", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@@ -4301,6 +4657,12 @@
"resolved": "https://registry.npmjs.org/plantuml-encoder/-/plantuml-encoder-1.4.0.tgz", "resolved": "https://registry.npmjs.org/plantuml-encoder/-/plantuml-encoder-1.4.0.tgz",
"integrity": "sha512-sxMwpDw/ySY1WB2CE3+IdMuEcWibJ72DDOsXLkSmEaSzwEUaYBT6DWgOfBiHGCux4q433X6+OEFWjlVqp7gL6g==" "integrity": "sha512-sxMwpDw/ySY1WB2CE3+IdMuEcWibJ72DDOsXLkSmEaSzwEUaYBT6DWgOfBiHGCux4q433X6+OEFWjlVqp7gL6g=="
}, },
"pluralize": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz",
"integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==",
"dev": true
},
"prelude-ls": { "prelude-ls": {
"version": "1.2.1", "version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
@@ -4325,6 +4687,21 @@
"prepend-file": "1.3.1" "prepend-file": "1.3.1"
} }
}, },
"prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"dev": true
},
"prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"requires": {
"fast-diff": "^1.1.2"
}
},
"process-nextick-args": { "process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@@ -4594,6 +4971,12 @@
"strip-indent": "^3.0.0" "strip-indent": "^3.0.0"
} }
}, },
"regexp-tree": {
"version": "0.1.24",
"resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.24.tgz",
"integrity": "sha512-s2aEVuLhvnVJW6s/iPgEGK6R+/xngd2jNQ+xy4bXNDKxZKJH6jpPHY6kVeVv1IeLCHgswRj+Kl3ELaDjG6V1iw==",
"dev": true
},
"regexpp": { "regexpp": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz",
@@ -4713,6 +5096,15 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
}, },
"safe-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz",
"integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==",
"dev": true,
"requires": {
"regexp-tree": "~0.1.1"
}
},
"safe-stable-stringify": { "safe-stable-stringify": {
"version": "2.3.1", "version": "2.3.1",
"resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz", "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz",
@@ -5272,6 +5664,12 @@
"sprintf-js": "~1.0.2" "sprintf-js": "~1.0.2"
} }
}, },
"builtin-modules": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
"integrity": "sha512-wxXCdllwGhI2kCC0MnvTGYTMvnVZTvqgypkiTI8Pa5tcz2i6VqsqwYGgqwXji+4RgCzms6EajE4IxiUH6HH8nQ==",
"dev": true
},
"chalk": { "chalk": {
"version": "2.4.2", "version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
@@ -5363,46 +5761,11 @@
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true "dev": true
}
}
},
"tslint-eslint-rules": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-5.4.0.tgz",
"integrity": "sha512-WlSXE+J2vY/VPgIcqQuijMQiel+UtmXS+4nvK4ZzlDiqBfXse8FAvkNnTcYhnQyOTW5KFM+uRRGXxYhFpuBc6w==",
"dev": true,
"requires": {
"doctrine": "0.7.2",
"tslib": "1.9.0",
"tsutils": "^3.0.0"
},
"dependencies": {
"doctrine": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz",
"integrity": "sha512-qiB/Rir6Un6Ad/TIgTRzsremsTGWzs8j7woXvp14jgq00676uBiBT5eUOi+FgRywZFVy5Us/c04ISRpZhRbS6w==",
"dev": true,
"requires": {
"esutils": "^1.1.6",
"isarray": "0.0.1"
}
},
"esutils": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz",
"integrity": "sha512-RG1ZkUT7iFJG9LSHr7KDuuMSlujfeTtMNIcInURxKAxhMtwQhI3NrQhz26gZQYlsYZQKzsnwtpKrFKj9K9Qu1A==",
"dev": true
},
"tslib": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz",
"integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==",
"dev": true
}, },
"tsutils": { "tsutils": {
"version": "3.21.0", "version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true, "dev": true,
"requires": { "requires": {
"tslib": "^1.8.1" "tslib": "^1.8.1"
@@ -5411,9 +5774,9 @@
} }
}, },
"tsutils": { "tsutils": {
"version": "2.29.0", "version": "3.21.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
"dev": true, "dev": true,
"requires": { "requires": {
"tslib": "^1.8.1" "tslib": "^1.8.1"
@@ -5524,10 +5887,9 @@
} }
}, },
"typescript": { "typescript": {
"version": "3.9.10", "version": "4.4.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.4.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", "integrity": "sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA=="
"dev": true
}, },
"uglify-js": { "uglify-js": {
"version": "3.16.2", "version": "3.16.2",

View File

@@ -2,7 +2,7 @@
"name": "@openstapps/api", "name": "@openstapps/api",
"version": "0.42.0", "version": "0.42.0",
"scripts": { "scripts": {
"build": "npm run tslint && npm run compile", "build": "npm run lint && npm run compile",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
"check-configuration": "openstapps-configuration", "check-configuration": "openstapps-configuration",
"compile": "rimraf lib && tsc && prepend lib/cli.js '#!/usr/bin/env node\n'", "compile": "rimraf lib && tsc && prepend lib/cli.js '#!/usr/bin/env node\n'",
@@ -12,7 +12,7 @@
"preversion": "npm run prepublishOnly", "preversion": "npm run prepublishOnly",
"push": "git push && git push origin \"v$npm_package_version\"", "push": "git push && git push origin \"v$npm_package_version\"",
"test": "nyc mocha --require ts-node/register --recursive 'test/*.spec.ts'", "test": "nyc mocha --require ts-node/register --recursive 'test/*.spec.ts'",
"tslint": "tslint -p tsconfig.json -c tslint.json 'src/**/*.ts'" "lint": "eslint --ext .ts src/"
}, },
"description": "Node.js library to interact with the StApps backend service", "description": "Node.js library to interact with the StApps backend service",
"dependencies": { "dependencies": {
@@ -42,7 +42,8 @@
}, },
"license": "GPL-3.0-only", "license": "GPL-3.0-only",
"devDependencies": { "devDependencies": {
"@openstapps/configuration": "0.29.1", "@openstapps/configuration": "0.32.0",
"@openstapps/eslint-config": "1.1.0",
"@testdeck/mocha": "0.2.0", "@testdeck/mocha": "0.2.0",
"@types/chai": "4.3.1", "@types/chai": "4.3.1",
"@types/chai-as-promised": "7.1.5", "@types/chai-as-promised": "7.1.5",
@@ -50,20 +51,28 @@
"@types/fs-extra": "9.0.13", "@types/fs-extra": "9.0.13",
"@types/json-schema": "7.0.11", "@types/json-schema": "7.0.11",
"@types/mocha": "9.1.1", "@types/mocha": "9.1.1",
"@typescript-eslint/eslint-plugin": "5.30.4",
"@typescript-eslint/parser": "5.30.4",
"chai": "4.3.6", "chai": "4.3.6",
"chai-as-promised": "7.1.1", "chai-as-promised": "7.1.1",
"chai-spies": "1.0.0", "chai-spies": "1.0.0",
"conventional-changelog-cli": "2.2.2", "conventional-changelog-cli": "2.2.2",
"eslint": "8.19.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jsdoc": "39.3.3",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-unicorn": "43.0.0",
"fs-extra": "10.1.0", "fs-extra": "10.1.0",
"mocha": "10.0.0", "mocha": "10.0.0",
"nock": "13.2.8", "nock": "13.2.8",
"nyc": "15.1.0", "nyc": "15.1.0",
"prepend-file-cli": "1.0.6", "prepend-file-cli": "1.0.6",
"prettier": "2.7.1",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"ts-node": "10.8.2", "ts-node": "10.8.2",
"tslint": "6.1.3", "tslint": "6.1.3",
"typedoc": "0.22.15", "typedoc": "0.22.15",
"typescript": "3.9.10" "typescript": "4.4.4"
}, },
"author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>", "author": "Karl-Philipp Wulfert <krlwlfrt@gmail.com>",
"contributors": [ "contributors": [
@@ -76,7 +85,7 @@
"Wieland Schöbl <wulkanat@gmail.com>" "Wieland Schöbl <wulkanat@gmail.com>"
], ],
"peerDependencies": { "peerDependencies": {
"@openstapps/core": "~0.66.0" "@openstapps/core": "~0.68.0"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -64,9 +64,13 @@ export class Bulk<T extends SCThings> {
throw new BulkWithMultipleTypesError(thing); throw new BulkWithMultipleTypesError(thing);
} }
return this.client.invokeRoute<SCBulkAddResponse>(this.bulkAddRoute, { return this.client.invokeRoute<SCBulkAddResponse>(
UID: encodeURIComponent(this.bulkResponse.uid), this.bulkAddRoute,
}, thing); {
UID: encodeURIComponent(this.bulkResponse.uid),
},
thing,
);
} }
/** /**
@@ -76,8 +80,12 @@ export class Bulk<T extends SCThings> {
* required in the backend so it might take a few seconds before the callback is called. * required in the backend so it might take a few seconds before the callback is called.
*/ */
async done(): Promise<SCBulkDoneResponse> { async done(): Promise<SCBulkDoneResponse> {
return this.client.invokeRoute<SCBulkDoneResponse>(this.bulkDoneRoute, { return this.client.invokeRoute<SCBulkDoneResponse>(
UID: this.bulkResponse.uid, this.bulkDoneRoute,
}, {}); {
UID: this.bulkResponse.uid,
},
{},
);
} }
} }

View File

@@ -16,41 +16,49 @@ import {SCThingType} from '@openstapps/core';
import {Logger} from '@openstapps/logger'; import {Logger} from '@openstapps/logger';
import {Command} from 'commander'; import {Command} from 'commander';
import {readFileSync} from 'fs'; import {readFileSync} from 'fs';
import {join} from 'path'; import path from 'path';
import {URL} from 'url'; import {URL} from 'url';
import waitOn from 'wait-on'; import waitOn from 'wait-on';
import {copy} from './copy'; import {copy} from './copy';
// eslint-disable-next-line unicorn/prevent-abbreviations
import {e2eRun} from './e2e'; import {e2eRun} from './e2e';
import {HttpClient} from './http-client'; import {HttpClient} from './http-client';
process.on('unhandledRejection', async (error) => { process.on('unhandledRejection', async error => {
await Logger.error('unhandledRejection', error); await Logger.error('unhandledRejection', error);
}); });
const pkgJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json')) // eslint-disable-next-line unicorn/prefer-module
.toString()); const packageJson = JSON.parse(readFileSync(path.join(__dirname, '..', 'package.json')).toString());
const client = new HttpClient(); const client = new HttpClient();
const commander = new Command(); const commander = new Command();
const helpAndExit = (help: string) => { const helpAndExit = (help: string) => {
// tslint:disable-next-line: no-console // eslint-disable-next-line no-console
console.log(help); console.log(help);
process.exit(-1); process.exit(-1);
}; };
commander commander
.command('e2e <to>') .command('e2e <to>')
.version(pkgJson.version) .version(packageJson.version)
.description('Run in end to end test mode. Indexing and afterwards retrieving all test files from @openstapp/core to the backend') .description(
.option('-s --samples [path]', 'Path to @openstapp/core test files', './node_modules/@openstapps/core/test/resources/indexable') 'Run in end to end test mode. Indexing and afterwards retrieving all test files from @openstapp/core to the backend',
)
.option(
'-s --samples [path]',
'Path to @openstapp/core test files',
'./node_modules/@openstapps/core/test/resources/indexable',
)
.option('-w --waiton [resource]', 'wait-on resource parameter see "www.npmjs.com/wait-on"') .option('-w --waiton [resource]', 'wait-on resource parameter see "www.npmjs.com/wait-on"')
// eslint-disable-next-line unicorn/prevent-abbreviations
.action(async (to, e2eCommand) => { .action(async (to, e2eCommand) => {
let toURL = ''; let toURL = '';
// validate url // validate url
try { try {
toURL = (new URL(to)).toString(); toURL = new URL(to).toString();
} catch (err) { } catch (error) {
await Logger.error('expected parameter <to> to be valid url', err); await Logger.error('expected parameter <to> to be valid url', error);
helpAndExit(e2eCommand.helpInformation()); helpAndExit(e2eCommand.helpInformation());
} }
@@ -59,13 +67,12 @@ commander
Logger.info(`Waiting for availibilty of resource: ${e2eCommand.waiton}`); Logger.info(`Waiting for availibilty of resource: ${e2eCommand.waiton}`);
await waitOn({ await waitOn({
resources: [e2eCommand.waiton], resources: [e2eCommand.waiton],
timeout: 300000, timeout: 300_000,
}); });
Logger.info(`Resource became available`); Logger.info(`Resource became available`);
} }
await e2eRun(client, {to: toURL, samplesLocation: e2eCommand.samples}); await e2eRun(client, {to: toURL, samplesLocation: e2eCommand.samples});
Logger.ok('Done'); Logger.ok('Done');
} catch (error) { } catch (error) {
await Logger.error(error); await Logger.error(error);
} }
@@ -73,7 +80,7 @@ commander
commander commander
.command('copy <type> <from> <to> <batchSize>') .command('copy <type> <from> <to> <batchSize>')
.version(pkgJson.version) .version(packageJson.version)
.description('Copy data from one instance to another') .description('Copy data from one instance to another')
.option( .option(
'-s, --bulkSource <bulkSource>', '-s, --bulkSource <bulkSource>',
@@ -84,7 +91,6 @@ commander
.option('-a, --appVersion <version>', 'The App version to use [unset by default]') .option('-a, --appVersion <version>', 'The App version to use [unset by default]')
.allowUnknownOption(false) .allowUnknownOption(false)
.action(async (type, from, to, batchSize, copyCommand) => { .action(async (type, from, to, batchSize, copyCommand) => {
// validate type // validate type
if (typeof type !== 'string') { if (typeof type !== 'string') {
await Logger.error('expected parameter "type" to be of type: string'); await Logger.error('expected parameter "type" to be of type: string');
@@ -97,15 +103,15 @@ commander
// validate urls // validate urls
try { try {
fromURL = (new URL(from)).toString(); fromURL = new URL(from).toString();
toURL = (new URL(to)).toString(); toURL = new URL(to).toString();
} catch (err) { } catch (error) {
await Logger.error('expected parameters "from" and "to" to be valid urls', err); await Logger.error('expected parameters "from" and "to" to be valid urls', error);
helpAndExit(copyCommand.helpInformation()); helpAndExit(copyCommand.helpInformation());
} }
// validate batchSize // validate batchSize
if (isNaN(parseInt(batchSize, 10))) { if (Number.isNaN(Number.parseInt(batchSize, 10))) {
await Logger.error('expected parameter "batchSize" to be of type: number'); await Logger.error('expected parameter "batchSize" to be of type: number');
helpAndExit(copyCommand.helpInformation()); helpAndExit(copyCommand.helpInformation());
} }
@@ -113,20 +119,20 @@ commander
Logger.info(`Copying ${type} objects from ${fromURL} to ${toURL}`); Logger.info(`Copying ${type} objects from ${fromURL} to ${toURL}`);
copy(client, { copy(client, {
batchSize: parseInt(batchSize, 10), batchSize: Number.parseInt(batchSize, 10),
from: fromURL, from: fromURL,
source: copyCommand.bulkSource, source: copyCommand.bulkSource,
to: toURL, to: toURL,
type: type as SCThingType, type: type as SCThingType,
version: copyCommand.appVersion, version: copyCommand.appVersion,
}) }).then(
.then(() => { () => {
Logger.ok('Done'); Logger.ok('Done');
}, (err) => { },
throw err; error => {
}); throw error;
},
);
}); });
commander commander.parse(process.argv);
.parse(process.argv);

View File

@@ -38,7 +38,6 @@ import {HttpClientHeaders, HttpClientInterface} from './http-client-interface';
* StApps-API client * StApps-API client
*/ */
export class Client { export class Client {
/** /**
* Instance of index route * Instance of index route
*/ */
@@ -161,10 +160,7 @@ export class Client {
* @param parameters Parameters for the URL fragment * @param parameters Parameters for the URL fragment
* @param body Body for the request * @param body Body for the request
*/ */
async invokePlugin<T>(name: string, async invokePlugin<T>(name: string, parameters?: {[k: string]: string}, body?: SCRequests): Promise<T> {
parameters?: { [k: string]: string; },
body?: SCRequests): Promise<T> {
if (typeof this.supportedFeatures === 'undefined') { if (typeof this.supportedFeatures === 'undefined') {
const request: SCIndexRequest = {}; const request: SCIndexRequest = {};
const response = await this.invokeRoute<SCIndexResponse>(this.indexRoute, undefined, request); const response = await this.invokeRoute<SCIndexResponse>(this.indexRoute, undefined, request);
@@ -191,9 +187,11 @@ export class Client {
* @param parameters Parameters for the URL fragment * @param parameters Parameters for the URL fragment
* @param body Body for the request * @param body Body for the request
*/ */
async invokeRoute<T>(route: SCAbstractRoute, async invokeRoute<T>(
parameters?: { [k: string]: string; }, route: SCAbstractRoute,
body?: SCRequests): Promise<T> { parameters?: {[k: string]: string},
body?: SCRequests,
): Promise<T> {
// make the request // make the request
const response = await this.httpClient.request({ const response = await this.httpClient.request({
body: body, body: body,
@@ -222,18 +220,17 @@ export class Client {
let preFlightNecessary = false; let preFlightNecessary = false;
// gather search requests where size is not set // gather search requests where size is not set
Object.keys(multiSearchRequest) for (const key of Object.keys(multiSearchRequest)) {
.forEach((key) => { const searchRequest = multiSearchRequest[key];
const searchRequest = multiSearchRequest[key];
if (typeof searchRequest.size === 'undefined') { if (typeof searchRequest.size === 'undefined') {
preFlightRequest[key] = { preFlightRequest[key] = {
...searchRequest, ...searchRequest,
}; };
preFlightRequest[key].size = 0; preFlightRequest[key].size = 0;
preFlightNecessary = true; preFlightNecessary = true;
} }
}); }
let returnMultiSearchRequest = multiSearchRequest; let returnMultiSearchRequest = multiSearchRequest;
@@ -251,14 +248,17 @@ export class Client {
); );
// set size for multi search requests that were in pre flight request // set size for multi search requests that were in pre flight request
Object.keys(preFlightRequest) for (const key of Object.keys(preFlightRequest)) {
.forEach((key) => { returnMultiSearchRequest[key].size = preFlightResponse[key].pagination.total;
returnMultiSearchRequest[key].size = preFlightResponse[key].pagination.total; }
});
} }
// actually invoke the route // actually invoke the route
return this.invokeRoute<SCMultiSearchResponse>(this.multiSearchRoute, undefined, returnMultiSearchRequest); return this.invokeRoute<SCMultiSearchResponse>(
this.multiSearchRoute,
undefined,
returnMultiSearchRequest,
);
} }
/** /**
@@ -292,7 +292,10 @@ export class Client {
* @param searchRequest Last search request * @param searchRequest Last search request
* @param searchResponse Search response for supplied search request * @param searchResponse Search response for supplied search request
*/ */
async searchNext(searchRequest: SCSearchRequest, searchResponse: SCSearchResponse): Promise<{ async searchNext(
searchRequest: SCSearchRequest,
searchResponse: SCSearchResponse,
): Promise<{
/* tslint:disable:completed-docs */ /* tslint:disable:completed-docs */
searchRequest: SCSearchRequest; searchRequest: SCSearchRequest;
searchResponse: SCSearchResponse; searchResponse: SCSearchResponse;

View File

@@ -40,6 +40,7 @@ export class ConnectorClient extends Client {
* The default timeout for the bulk to expire * The default timeout for the bulk to expire
*/ */
static readonly BULK_TIMEOUT = 3600; static readonly BULK_TIMEOUT = 3600;
/** /**
* The limit of how many items should be indexed concurrently * The limit of how many items should be indexed concurrently
*/ */
@@ -58,7 +59,7 @@ export class ConnectorClient extends Client {
/** /**
* Make a UUID from a UID and a namespace ID * Make a UUID from a UID and a namespace ID
* *
* *Note: valid namespace IDs are license plates of StApps universities. * Note: valid namespace IDs are license plates of StApps universities.
* See documentation of `NAMESPACES` for valid namespace IDs.* * See documentation of `NAMESPACES` for valid namespace IDs.*
* *
* @param uid UID to make UUID from * @param uid UID to make UUID from
@@ -80,15 +81,13 @@ export class ConnectorClient extends Client {
* @param thing Thing to remove references from * @param thing Thing to remove references from
*/ */
static removeReferences<THING extends SCThings>(thing: THING): SCAssociatedThingWithoutReferences<THING> { static removeReferences<THING extends SCThings>(thing: THING): SCAssociatedThingWithoutReferences<THING> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// tslint:disable-next-line:no-any
const thingWithoutReferences = clone()<any>(thing); const thingWithoutReferences = clone()<any>(thing);
delete thingWithoutReferences.origin; delete thingWithoutReferences.origin;
// iterate over all properties // iterate over all properties
for (const key in thingWithoutReferences) { for (const key in thingWithoutReferences) {
/* istanbul ignore if */ /* istanbul ignore if */
if (!thingWithoutReferences.hasOwnProperty(key)) { if (!thingWithoutReferences.hasOwnProperty(key)) {
continue; continue;
@@ -111,7 +110,7 @@ export class ConnectorClient extends Client {
} else { } else {
// check every item in array // check every item in array
for (const item of property) { for (const item of property) {
if (['boolean', 'number', 'string'].indexOf(typeof item) >= 0) { if (['boolean', 'number', 'string'].includes(typeof item)) {
// skip primitives // skip primitives
continue; continue;
} }
@@ -147,29 +146,29 @@ export class ConnectorClient extends Client {
/** /**
* Recursively deletes all undefined properties from an object instance * Recursively deletes all undefined properties from an object instance
* *
* @param obj Object to delete undefined properties from * @param object Object to delete undefined properties from
*/ */
static removeUndefinedProperties(obj: object): void { static removeUndefinedProperties(object: object): void {
// return atomic data types and arrays (recursion anchor) // return atomic data types and arrays (recursion anchor)
if (typeof obj !== 'object' || Array.isArray(obj)) { if (typeof object !== 'object' || Array.isArray(object)) {
return; return;
} }
// check each key // check each key
for (const key in obj) { for (const key in object) {
/* istanbul ignore if */ /* istanbul ignore if */
if (!obj.hasOwnProperty(key)) { if (!object.hasOwnProperty(key)) {
continue; continue;
} }
const indexedObj = obj as { [k: string]: unknown; }; const indexedObject = object as {[k: string]: unknown};
if (typeof indexedObj[key] === 'undefined') { if (typeof indexedObject[key] === 'undefined') {
// delete undefined keyss // delete undefined keyss
delete indexedObj[key]; delete indexedObject[key];
} else { } else {
// check recursive // check recursive
ConnectorClient.removeUndefinedProperties(indexedObj[key] as object); ConnectorClient.removeUndefinedProperties(indexedObject[key] as object);
} }
} }
@@ -187,18 +186,11 @@ export class ConnectorClient extends Client {
* @param timeout Timeout in seconds when the bulk should expire * @param timeout Timeout in seconds when the bulk should expire
*/ */
async bulk<T extends SCThings>(type: SCThingType, source: string, timeout?: number): Promise<Bulk<T>> { async bulk<T extends SCThings>(type: SCThingType, source: string, timeout?: number): Promise<Bulk<T>> {
let bulkTimeout: number;
// set default value for timeout to one hour // set default value for timeout to one hour
if (typeof timeout !== 'number') { const bulkTimeout = typeof timeout !== 'number' ? ConnectorClient.BULK_TIMEOUT : timeout;
bulkTimeout = ConnectorClient.BULK_TIMEOUT;
} else {
bulkTimeout = timeout;
}
const bulkData = await this.invokeRoute<SCBulkResponse>(this.bulkRoute, undefined, { const bulkData = await this.invokeRoute<SCBulkResponse>(this.bulkRoute, undefined, {
expiration: moment() expiration: moment().add(bulkTimeout, 'seconds').format(),
.add(bulkTimeout, 'seconds')
.format(),
source: source, source: source,
type: type, type: type,
}); });
@@ -223,19 +215,14 @@ export class ConnectorClient extends Client {
throw new EmptyBulkError(); throw new EmptyBulkError();
} }
let thingSource: string;
// set default source if none is given // set default source if none is given
if (typeof source === 'undefined') { const thingSource = typeof source === 'undefined' ? 'stapps-api' : source;
thingSource = 'stapps-api';
} else {
thingSource = source;
}
// request a new bulk // request a new bulk
const bulk = await this.bulk(things[0].type, thingSource, timeout); const bulk = await this.bulk(things[0].type, thingSource, timeout);
// add items to the bulk - 5 concurrently // add items to the bulk - 5 concurrently
await asyncPool(ConnectorClient.ITEM_CONCURRENT_LIMIT, things, (thing) => bulk.add(thing)); await asyncPool(ConnectorClient.ITEM_CONCURRENT_LIMIT, things, thing => bulk.add(thing));
// close bulk // close bulk
await bulk.done(); await bulk.done();
@@ -247,9 +234,13 @@ export class ConnectorClient extends Client {
* @param thing StAppsCore thing to update * @param thing StAppsCore thing to update
*/ */
async update(thing: SCThings): Promise<SCThingUpdateResponse> { async update(thing: SCThings): Promise<SCThingUpdateResponse> {
return this.invokeRoute<SCThingUpdateResponse>(this.thingUpdateRoute, { return this.invokeRoute<SCThingUpdateResponse>(
TYPE: encodeURIComponent(thing.type), this.thingUpdateRoute,
UID: encodeURIComponent(thing.uid), {
}, thing); TYPE: encodeURIComponent(thing.type),
UID: encodeURIComponent(thing.uid),
},
thing,
);
} }
} }

View File

@@ -62,7 +62,6 @@ export interface CopyOptions {
* @param options Map of options * @param options Map of options
*/ */
export async function copy(client: HttpClientInterface, options: CopyOptions): Promise<void> { export async function copy(client: HttpClientInterface, options: CopyOptions): Promise<void> {
const apiIn = new Client(client, options.from, options.version); const apiIn = new Client(client, options.from, options.version);
const apiOut = new ConnectorClient(client, options.to); const apiOut = new ConnectorClient(client, options.to);
@@ -93,17 +92,17 @@ export async function copy(client: HttpClientInterface, options: CopyOptions): P
try { try {
({searchRequest, searchResponse} = await apiIn.searchNext(searchRequest, searchResponse)); ({searchRequest, searchResponse} = await apiIn.searchNext(searchRequest, searchResponse));
await asyncPool(ConnectorClient.ITEM_CONCURRENT_LIMIT, searchResponse.data, async (item) => { await asyncPool(ConnectorClient.ITEM_CONCURRENT_LIMIT, searchResponse.data, async item => {
progressBar.increment(1); progressBar.increment(1);
return bulk.add(item); return bulk.add(item);
}); });
} catch (e) { } catch (error) {
if (e instanceof OutOfRangeError) { if (error instanceof OutOfRangeError) {
outOfRange = true; outOfRange = true;
} else { } else {
progressBar.stop(); progressBar.stop();
throw e; throw error;
} }
} }
} while (!outOfRange); } while (!outOfRange);

View File

@@ -12,12 +12,13 @@
* You should have received a copy of the GNU General Public License along with * You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>. * this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/* eslint-disable unicorn/prevent-abbreviations */
import {SCSearchRequest, SCThings, SCThingType} from '@openstapps/core'; import {SCSearchRequest, SCThings, SCThingType} from '@openstapps/core';
import {Logger} from '@openstapps/logger'; import {Logger} from '@openstapps/logger';
import {deepStrictEqual} from 'assert'; import {deepStrictEqual} from 'assert';
import {readdir, readFile} from 'fs'; import {readdir, readFile} from 'fs';
import {join} from 'path'; import path from 'path';
import {promisify} from 'util'; import {promisify} from 'util';
import {ConnectorClient} from './connector-client'; import {ConnectorClient} from './connector-client';
import {HttpClientInterface} from './http-client-interface'; import {HttpClientInterface} from './http-client-interface';
@@ -79,7 +80,9 @@ async function retrieveItems(api: ConnectorClient): Promise<void> {
singleItemSearchRequest.filter!.arguments.value = uid; singleItemSearchRequest.filter!.arguments.value = uid;
const searchResonse = await api.search(singleItemSearchRequest); const searchResonse = await api.search(singleItemSearchRequest);
if (searchResonse.data.length !== 1) { if (searchResonse.data.length !== 1) {
throw Error(`Search for single SCThing with uid: ${uid} returned ${searchResonse.data.length} results`); throw new Error(
`Search for single SCThing with uid: ${uid} returned ${searchResonse.data.length} results`,
);
} }
remoteItemMap.set(uid, searchResonse.data[0]); remoteItemMap.set(uid, searchResonse.data[0]);
} }
@@ -92,12 +95,14 @@ function compareItems() {
for (const localThing of localItemMap.values()) { for (const localThing of localItemMap.values()) {
/* istanbul ignore next retrieveItems will throw before*/ /* istanbul ignore next retrieveItems will throw before*/
if (!remoteItemMap.has(localThing.uid)) { if (!remoteItemMap.has(localThing.uid)) {
throw Error(`Did not retrieve expected SCThing with uid: ${localThing.uid}`); throw new Error(`Did not retrieve expected SCThing with uid: ${localThing.uid}`);
} }
const remoteThing = remoteItemMap.get(localThing.uid); const remoteThing = remoteItemMap.get(localThing.uid);
deepStrictEqual(remoteThing, localThing, `Unexpected difference between original and retrieved sample`); deepStrictEqual(remoteThing, localThing, `Unexpected difference between original and retrieved sample`);
} }
Logger.info(`All samples retrieved from the backend are the same (deep equal) as the original ones submitted`); Logger.info(
`All samples retrieved from the backend are the same (deep equal) as the original ones submitted`,
);
} }
/** /**
* Function to add all the SCThings that getItemsFromSamples() returns to the backend * Function to add all the SCThings that getItemsFromSamples() returns to the backend
@@ -125,8 +130,8 @@ async function indexSamples(api: ConnectorClient, options: E2EOptions): Promise<
for (const type of itemMap.keys()) { for (const type of itemMap.keys()) {
await api.index(itemMap.get(type) as SCThings[], 'stapps-core-sample-data'); await api.index(itemMap.get(type) as SCThings[], 'stapps-core-sample-data');
} }
} catch (err) { } catch (error) {
throw err; throw error;
} }
} }
@@ -144,7 +149,7 @@ export async function getItemsFromSamples<T extends SCThings>(samplesDirectory:
try { try {
const fileNames = await readDirPromised(samplesDirectory); const fileNames = await readDirPromised(samplesDirectory);
for (const fileName of fileNames) { for (const fileName of fileNames) {
const filePath = join(samplesDirectory, fileName); const filePath = path.join(samplesDirectory, fileName);
if (filePath.endsWith('.json')) { if (filePath.endsWith('.json')) {
const fileContent = await readFilePromised(filePath, {encoding: 'utf8'}); const fileContent = await readFilePromised(filePath, {encoding: 'utf8'});
const schemaObject = JSON.parse(fileContent); const schemaObject = JSON.parse(fileContent);

View File

@@ -35,19 +35,19 @@ export class ApiError extends Error {
* Add additional data to the output of the error * Add additional data to the output of the error
*/ */
toString(): string { toString(): string {
let str = super.toString(); let string_ = super.toString();
// add additional data // add additional data
if (typeof this.data.additionalData !== 'undefined') { if (typeof this.data.additionalData !== 'undefined') {
str += `\n\n${JSON.stringify(this.data.additionalData)}`; string_ += `\n\n${JSON.stringify(this.data.additionalData)}`;
} }
// add "remote" stack trace // add "remote" stack trace
if (typeof this.data.stack !== 'undefined') { if (typeof this.data.stack !== 'undefined') {
str += `\n\n${this.data.stack}`; string_ += `\n\n${this.data.stack}`;
} }
return str; return string_;
} }
} }
@@ -135,7 +135,7 @@ export class CoreVersionIncompatibleError extends ApiError {
/** /**
* Error that is thrown when API and backend StAppsCore versions are incompatible * Error that is thrown when API and backend StAppsCore versions are incompatible
*/ */
export class PluginNotAvailableError extends ApiError { export class PluginNotAvailableError extends ApiError {
/** /**
* Instantiate a new error * Instantiate a new error
*/ */

View File

@@ -23,18 +23,15 @@ export interface HttpClientInterface {
* *
* @param request Request to send * @param request Request to send
*/ */
request<T extends SCResponses>( request<T extends SCResponses>(request: HttpClientRequest): Promise<HttpClientResponse<T>>;
request: HttpClientRequest,
): Promise<HttpClientResponse<T>>;
} }
/** /**
* A map of headers * A map of headers
*/ */
export interface HttpClientHeaders { export interface HttpClientHeaders {
/* tslint:disable:no-any */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any; [key: string]: any;
/* tslint:enable:no-any */
} }
/** /**

View File

@@ -22,7 +22,8 @@ export interface RequestOptions extends Omit<OptionsOfJSONResponseBody, 'json' |
/** /**
* Body of the request * Body of the request
*/ */
// tslint:disable-next-line:no-any TODO: Use a specific type? // TODO: Use a specific type?
// eslint-disable-next-line @typescript-eslint/no-explicit-any
body?: any; body?: any;
/** /**
* Target URL of the request * Target URL of the request
@@ -46,40 +47,38 @@ export interface Response<TYPE_OF_BODY> extends GotResponse {
export class HttpClient { export class HttpClient {
/** /**
* Make a request * Make a request
*
* @param requestConfig Configuration of the request * @param requestConfig Configuration of the request
*/ */
// tslint:disable-next-line:prefer-function-over-method async request<TYPE_OF_BODY>(requestConfig: RequestOptions): Promise<Response<TYPE_OF_BODY>> {
async request<TYPE_OF_BODY>( const parameters: OptionsOfJSONResponseBody = {
requestConfig: RequestOptions,
): Promise<Response<TYPE_OF_BODY>> {
const params: OptionsOfJSONResponseBody = {
followRedirect: true, followRedirect: true,
method: 'GET', method: 'GET',
responseType: 'json', responseType: 'json',
}; };
if (typeof requestConfig.body !== 'undefined') { if (typeof requestConfig.body !== 'undefined') {
params.json = requestConfig.body; parameters.json = requestConfig.body;
} }
if (typeof requestConfig.headers !== 'undefined') { if (typeof requestConfig.headers !== 'undefined') {
params.headers = requestConfig.headers; parameters.headers = requestConfig.headers;
} }
if (typeof requestConfig.method !== 'undefined') { if (typeof requestConfig.method !== 'undefined') {
params.method = requestConfig.method; parameters.method = requestConfig.method;
} }
let response: Response<TYPE_OF_BODY>; let response: Response<TYPE_OF_BODY>;
try { try {
response = await got(requestConfig.url.toString(), params); response = await got(requestConfig.url.toString(), parameters);
} catch (err) { } catch (error) {
// tslint:disable-next-line: no-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
if (typeof (err as any).response === 'undefined') { if (typeof (error as any).response === 'undefined') {
throw err; throw error;
} }
// if there is a response (e.g. response with statusCode 404 etc.) provide it // if there is a response (e.g. response with statusCode 404 etc.) provide it
// tslint:disable-next-line: no-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
response = (err as any).response as Response<TYPE_OF_BODY>; response = (error as any).response as Response<TYPE_OF_BODY>;
} }
return response; return response;

View File

@@ -53,7 +53,7 @@ export class PluginClient extends ConnectorClient {
* *
* **This method automatically calls [[Plugin.stop]]** * **This method automatically calls [[Plugin.stop]]**
* If you want to unregister your plugin for some reason, you can do so by calling this method. * If you want to unregister your plugin for some reason, you can do so by calling this method.
* *Use with caution.* * Use with caution.*
* *
* @param plugin The instance of the plugin you want to register * @param plugin The instance of the plugin you want to register
*/ */

View File

@@ -60,10 +60,12 @@ export abstract class Plugin {
* The port on which the plugin will listen on * The port on which the plugin will listen on
*/ */
public port: string | number | false; public port: string | number | false;
/** /**
* The schema of the request interfaces defined by the user * The schema of the request interfaces defined by the user
*/ */
public readonly requestSchema: JSONSchema7 = {}; public readonly requestSchema: JSONSchema7 = {};
/** /**
* The schema of the response interfaces defined by the user * The schema of the response interfaces defined by the user
*/ */
@@ -75,10 +77,10 @@ export abstract class Plugin {
* @param value the port you want to normalize * @param value the port you want to normalize
*/ */
protected static normalizePort(value: string) { protected static normalizePort(value: string) {
const portNumber = parseInt(value, 10); const portNumber = Number.parseInt(value, 10);
/* istanbul ignore next */ /* istanbul ignore next */
if (isNaN(portNumber)) { if (Number.isNaN(portNumber)) {
// named pipe // named pipe
/* istanbul ignore next */ /* istanbul ignore next */
return value; return value;
@@ -110,29 +112,31 @@ export abstract class Plugin {
* @param responseName the name of the response schema * @param responseName the name of the response schema
* @param version the version. You should retrieve it from the package.json * @param version the version. You should retrieve it from the package.json
*/ */
constructor(port: number, constructor(
public name: string, port: number,
public url: string, public name: string,
public route: string, public url: string,
protected backendUrl: string, public route: string,
converter: Converter, protected backendUrl: string,
requestName: string, converter: Converter,
responseName: string, requestName: string,
version: string) { responseName: string,
version: string,
) {
this.app.use(bodyParser.json()); this.app.use(bodyParser.json());
this.port = Plugin.normalizePort( this.port = Plugin.normalizePort(
/* istanbul ignore next */ /* istanbul ignore next */
typeof process.env.PORT !== 'undefined' ? process.env.PORT : port.toString()); typeof process.env.PORT !== 'undefined' ? process.env.PORT : port.toString(),
);
this.app.set('port', this.port); this.app.set('port', this.port);
// setup express // setup express
this.server = http.createServer(this.app); this.server = http.createServer(this.app);
this.server.listen(this.port); this.server.listen(this.port);
/* istanbul ignore next */ /* istanbul ignore next */
this.server.on('error', (err) => { this.server.on('error', error => {
/* istanbul ignore next */ /* istanbul ignore next */
this.onError(err); this.onError(error);
}); });
this.server.on('listening', () => { this.server.on('listening', () => {
this.onListening(); this.onListening();
@@ -145,12 +149,12 @@ export abstract class Plugin {
this.app.set('env', process.env.NODE_ENV); this.app.set('env', process.env.NODE_ENV);
this.app.all('*', async (req: express.Request, res: express.Response) => { this.app.all('*', async (request: express.Request, response: express.Response) => {
if (this.active) { if (this.active) {
await this.onRouteInvoke(req, res); await this.onRouteInvoke(request, response);
} else { } else {
res.status(http2.constants.HTTP_STATUS_NOT_FOUND); response.status(http2.constants.HTTP_STATUS_NOT_FOUND);
res.send(); response.send();
} }
}); });
} }
@@ -167,9 +171,7 @@ export abstract class Plugin {
throw error; throw error;
} }
const bind = typeof this.port === 'string' const bind = typeof this.port === 'string' ? `Pipe ${this.port}` : `Port ${this.port}`;
? `Pipe ${this.port}`
: `Port ${this.port}`;
// handle specific listen errors with friendly messages // handle specific listen errors with friendly messages
switch (error.code) { switch (error.code) {
@@ -194,9 +196,7 @@ export abstract class Plugin {
private onListening() { private onListening() {
const addr = this.server.address(); const addr = this.server.address();
/* istanbul ignore next */ /* istanbul ignore next */
const bind = typeof addr === 'string' const bind = typeof addr === 'string' ? `pipe ${addr}` : addr === null ? 'null' : `port ${addr.port}`;
? `pipe ${addr}` : addr === null
? 'null' : `port ${addr.port}`;
Logger.ok(`Listening on ${bind}`); Logger.ok(`Listening on ${bind}`);
} }
@@ -205,10 +205,10 @@ export abstract class Plugin {
* *
* Override this method for your own plugin * Override this method for your own plugin
* *
* @param req An express Request from the backend * @param request An express Request from the backend
* @param res An express Response to the backend for you to send back data * @param response An express Response to the backend for you to send back data
*/ */
protected abstract onRouteInvoke(req: express.Request, res: express.Response): Promise<void>; protected abstract onRouteInvoke(request: express.Request, response: express.Response): Promise<void>;
/** /**
* Closes the server * Closes the server
@@ -218,11 +218,11 @@ export abstract class Plugin {
*/ */
public async close() { public async close() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.server.close((err) => { this.server.close(error => {
/* istanbul ignore next */ /* istanbul ignore next */
if (typeof err !== 'undefined') { if (typeof error !== 'undefined') {
/* istanbul ignore next */ /* istanbul ignore next */
reject(err); reject(error);
} }
resolve(undefined); resolve(undefined);
}); });

View File

@@ -1,3 +0,0 @@
{
"extends": "./node_modules/@openstapps/configuration/tslint.json"
}