fix(general): tslint being applied in all sources.

This commit is contained in:
Rodrigo Rodriguez 2019-03-08 19:13:00 -03:00
parent 2c185177a8
commit d717de6245
33 changed files with 458 additions and 645 deletions

View file

@ -5,4 +5,5 @@
"arrowParens": "avoid", "arrowParens": "avoid",
"semi": true, "semi": true,
"singleQuote": true "singleQuote": true
} }

347
package-lock.json generated
View file

@ -986,15 +986,6 @@
"resolved": "https://registry.npmjs.org/@kyleshockey/object-assign-deep/-/object-assign-deep-0.4.2.tgz", "resolved": "https://registry.npmjs.org/@kyleshockey/object-assign-deep/-/object-assign-deep-0.4.2.tgz",
"integrity": "sha1-hJAPDu/DcnmPR1G1JigwuCCJIuw=" "integrity": "sha1-hJAPDu/DcnmPR1G1JigwuCCJIuw="
}, },
"@microsoft/microsoft-graph-client": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@microsoft/microsoft-graph-client/-/microsoft-graph-client-1.4.0.tgz",
"integrity": "sha512-dX7053APLpIaGMGqJrDjBVX7ZO+vntKTvyB1WIy4WpC8qE3qdE68MDOq5Vv6JPG879KygPiCH2ex5RCAK+OR0Q==",
"requires": {
"es6-promise": "^4.1.0",
"isomorphic-fetch": "^2.2.1"
}
},
"@microsoft/recognizers-text": { "@microsoft/recognizers-text": {
"version": "1.1.4", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.1.4.tgz", "resolved": "https://registry.npmjs.org/@microsoft/recognizers-text/-/recognizers-text-1.1.4.tgz",
@ -1606,7 +1597,7 @@
"@types/is-stream": { "@types/is-stream": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/@types/is-stream/-/is-stream-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@types/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha1-uE17sgeiEPKvm+1DHcD76cQUO+E=", "integrity": "sha512-jkZatu4QVbR60mpIzjINmtS1ZF4a/FqdTUTBeQDVOQ2PYyidtwFKr0B5G6ERukKwliq+7mIXvxyppwzG5EgRYg==",
"requires": { "requires": {
"@types/node": "*" "@types/node": "*"
} }
@ -1647,7 +1638,7 @@
"@types/node-fetch": { "@types/node-fetch": {
"version": "1.6.9", "version": "1.6.9",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-1.6.9.tgz", "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-1.6.9.tgz",
"integrity": "sha1-p1D7D0zylgv3K0YuTIaQgCLdacU=", "integrity": "sha512-n2r6WLoY7+uuPT7pnEtKJCmPUGyJ+cbyBR8Avnu4+m1nzz7DwBVuyIvvlBzCZ/nrpC7rIgb3D6pNavL7rFEa9g==",
"requires": { "requires": {
"@types/node": "*" "@types/node": "*"
} }
@ -1671,23 +1662,6 @@
"@types/request": "*" "@types/request": "*"
} }
}, },
"@types/semver": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz",
"integrity": "sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ=="
},
"@types/sequelize": {
"version": "4.27.38",
"resolved": "https://registry.npmjs.org/@types/sequelize/-/sequelize-4.27.38.tgz",
"integrity": "sha512-HR+epHzmU8xSMRUjhuuYKHn3IxD2Ft4OePEqXY8/6otDyPn9s6SZx4bVLnUa98jv6Ny0Di9IHQHOXh35O7QajQ==",
"dev": true,
"requires": {
"@types/bluebird": "*",
"@types/continuation-local-storage": "*",
"@types/lodash": "*",
"@types/validator": "*"
}
},
"@types/shelljs": { "@types/shelljs": {
"version": "0.8.2", "version": "0.8.2",
"resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.2.tgz", "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.2.tgz",
@ -1711,7 +1685,7 @@
"@types/uuid": { "@types/uuid": {
"version": "3.4.4", "version": "3.4.4",
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.4.tgz",
"integrity": "sha1-evaTYPpl7w3stB/RUL9MpcDO/fU=", "integrity": "sha512-tPIgT0GUmdJQNSHxp0X2jnpQfBSTfGxUMc/2CXBU2mnyTFVYVa2ojpoQ74w0U2yn2vw3jnC640+77lkFFpdVDw==",
"requires": { "requires": {
"@types/node": "*" "@types/node": "*"
} }
@ -2030,11 +2004,6 @@
"readable-stream": "^2.0.6" "readable-stream": "^2.0.6"
} }
}, },
"arg": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.0.tgz",
"integrity": "sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg=="
},
"argparse": { "argparse": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
@ -2789,6 +2758,28 @@
"ms-rest-js": "^0.2.5", "ms-rest-js": "^0.2.5",
"request": "2.83.0", "request": "2.83.0",
"rsa-pem-from-mod-exp": "^0.8.4" "rsa-pem-from-mod-exp": "^0.8.4"
},
"dependencies": {
"ms-rest-js": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/ms-rest-js/-/ms-rest-js-0.2.8.tgz",
"integrity": "sha512-KgiSsbJzKcPLx0Zaca5PEdGOwm8X4Np+aTukK6stMl2eAqSrHvncjteyeXi6v6O0ECLYeUWVbqcPJfpw1PjnZQ==",
"requires": {
"@types/form-data": "^2.2.1",
"@types/is-stream": "^1.1.0",
"@types/node": "^9.4.6",
"@types/node-fetch": "^1.6.7",
"@types/uuid": "^3.4.3",
"fetch-cookie": "^0.7.0",
"fetch-ponyfill": "github:amarzavery/fetch-ponyfill#master",
"form-data": "^2.3.2",
"is-buffer": "^2.0.0",
"is-stream": "^1.1.0",
"moment": "^2.21.0",
"url-parse": "^1.2.0",
"uuid": "^3.2.1"
}
}
} }
}, },
"botframework-schema": { "botframework-schema": {
@ -2808,6 +2799,11 @@
"har-schema": "^2.0.0" "har-schema": "^2.0.0"
} }
}, },
"is-buffer": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz",
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw=="
},
"oauth-sign": { "oauth-sign": {
"version": "0.8.2", "version": "0.8.2",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
@ -3007,6 +3003,28 @@
"ms-rest-js": "^0.2.5", "ms-rest-js": "^0.2.5",
"request": "2.83.0", "request": "2.83.0",
"rsa-pem-from-mod-exp": "^0.8.4" "rsa-pem-from-mod-exp": "^0.8.4"
},
"dependencies": {
"ms-rest-js": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/ms-rest-js/-/ms-rest-js-0.2.8.tgz",
"integrity": "sha512-KgiSsbJzKcPLx0Zaca5PEdGOwm8X4Np+aTukK6stMl2eAqSrHvncjteyeXi6v6O0ECLYeUWVbqcPJfpw1PjnZQ==",
"requires": {
"@types/form-data": "^2.2.1",
"@types/is-stream": "^1.1.0",
"@types/node": "^9.4.6",
"@types/node-fetch": "^1.6.7",
"@types/uuid": "^3.4.3",
"fetch-cookie": "^0.7.0",
"fetch-ponyfill": "github:amarzavery/fetch-ponyfill#master",
"form-data": "^2.3.2",
"is-buffer": "^2.0.0",
"is-stream": "^1.1.0",
"moment": "^2.21.0",
"url-parse": "^1.2.0",
"uuid": "^3.2.1"
}
}
} }
}, },
"botframework-schema": { "botframework-schema": {
@ -3026,6 +3044,11 @@
"har-schema": "^2.0.0" "har-schema": "^2.0.0"
} }
}, },
"is-buffer": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz",
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw=="
},
"oauth-sign": { "oauth-sign": {
"version": "0.8.2", "version": "0.8.2",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
@ -3779,11 +3802,6 @@
"restore-cursor": "^2.0.0" "restore-cursor": "^2.0.0"
} }
}, },
"cli-spinner": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/cli-spinner/-/cli-spinner-0.2.8.tgz",
"integrity": "sha1-gWnZ/66HBnZEXm7kOX6Vp6Fb2AU="
},
"cli-table": { "cli-table": {
"version": "0.3.1", "version": "0.3.1",
"resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz", "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz",
@ -4058,12 +4076,6 @@
"delayed-stream": "~1.0.0" "delayed-stream": "~1.0.0"
} }
}, },
"commander": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==",
"dev": true
},
"commitizen": { "commitizen": {
"version": "3.0.7", "version": "3.0.7",
"resolved": "https://registry.npmjs.org/commitizen/-/commitizen-3.0.7.tgz", "resolved": "https://registry.npmjs.org/commitizen/-/commitizen-3.0.7.tgz",
@ -4250,15 +4262,6 @@
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
}, },
"config-chain": {
"version": "1.1.12",
"resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.12.tgz",
"integrity": "sha512-a1eOIcu8+7lUInge4Rpf/n4Krkf3Dd9lqhljRzII1/Zno/kRtUWnznPO3jOKBmTEktkt3fkxisUcivoj0ebzoA==",
"requires": {
"ini": "^1.3.4",
"proto-list": "~1.2.1"
}
},
"configstore": { "configstore": {
"version": "3.1.2", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz", "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz",
@ -5308,31 +5311,6 @@
"safe-buffer": "^5.0.1" "safe-buffer": "^5.0.1"
} }
}, },
"editorconfig": {
"version": "0.15.2",
"resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.2.tgz",
"integrity": "sha512-GWjSI19PVJAM9IZRGOS+YKI8LN+/sjkSjNyvxL5ucqP9/IqtYNXBaQ/6c/hkPNYQHyOHra2KoXZI/JVpuqwmcQ==",
"requires": {
"@types/node": "^10.11.7",
"@types/semver": "^5.5.0",
"commander": "^2.19.0",
"lru-cache": "^4.1.3",
"semver": "^5.6.0",
"sigmund": "^1.0.1"
},
"dependencies": {
"commander": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz",
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg=="
},
"semver": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg=="
}
}
},
"ee-first": { "ee-first": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@ -5495,7 +5473,8 @@
"es6-promise": { "es6-promise": {
"version": "4.2.5", "version": "4.2.5",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz", "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.5.tgz",
"integrity": "sha1-2m0NVpLvtGHggsFIF/4kJ9j10FQ=" "integrity": "sha1-2m0NVpLvtGHggsFIF/4kJ9j10FQ=",
"dev": true
}, },
"es6-promisify": { "es6-promisify": {
"version": "5.0.0", "version": "5.0.0",
@ -6014,12 +5993,31 @@
"fetch-cookie": { "fetch-cookie": {
"version": "0.7.2", "version": "0.7.2",
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.7.2.tgz", "resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.7.2.tgz",
"integrity": "sha1-W+US9xIbC80uNENQrXF3J6w7Gl0=", "integrity": "sha512-Udm6ls1tV/pR9+EOjTYW2aGBadN03zOgVwu6grybxOg9ufACq7wE1HY/jh06DOykXH9FLYJC2RbUD3kJZcJBRg==",
"requires": { "requires": {
"es6-denodeify": "^0.1.1", "es6-denodeify": "^0.1.1",
"tough-cookie": "^2.3.1" "tough-cookie": "^2.3.1"
} }
}, },
"fetch-ponyfill": {
"version": "github:amarzavery/fetch-ponyfill#136e6f8192bdb2aa0b7983f0b3b4361c357be9db",
"from": "github:amarzavery/fetch-ponyfill#master",
"requires": {
"fetch-cookie": "~0.6.0",
"node-fetch": "~1.7.1"
},
"dependencies": {
"fetch-cookie": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.6.0.tgz",
"integrity": "sha1-T+xOQIzAAH9sBOVTYYr0s97jf2k=",
"requires": {
"es6-denodeify": "^0.1.1",
"tough-cookie": "^2.3.1"
}
}
}
},
"figures": { "figures": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
@ -8207,15 +8205,6 @@
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
"integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
}, },
"isomorphic-fetch": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
"integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=",
"requires": {
"node-fetch": "^1.0.1",
"whatwg-fetch": ">=0.10.0"
}
},
"isomorphic-form-data": { "isomorphic-form-data": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/isomorphic-form-data/-/isomorphic-form-data-0.0.1.tgz", "resolved": "https://registry.npmjs.org/isomorphic-form-data/-/isomorphic-form-data-0.0.1.tgz",
@ -8285,33 +8274,6 @@
"integrity": "sha512-CpKJh9VRNhS+XqZtg1UMejETGEiqwCGDC/uwPEEQwc2nfdbSm73SIE29TplG2gLYuBOOTNDqxzG6A9NtEPLt0w==", "integrity": "sha512-CpKJh9VRNhS+XqZtg1UMejETGEiqwCGDC/uwPEEQwc2nfdbSm73SIE29TplG2gLYuBOOTNDqxzG6A9NtEPLt0w==",
"dev": true "dev": true
}, },
"js-beautify": {
"version": "1.8.9",
"resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.8.9.tgz",
"integrity": "sha512-MwPmLywK9RSX0SPsUJjN7i+RQY9w/yC17Lbrq9ViEefpLRgqAR2BgrMN2AbifkUuhDV8tRauLhLda/9+bE0YQA==",
"requires": {
"config-chain": "^1.1.12",
"editorconfig": "^0.15.2",
"glob": "^7.1.3",
"mkdirp": "~0.5.0",
"nopt": "~4.0.1"
},
"dependencies": {
"glob": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
}
}
},
"js-levenshtein": { "js-levenshtein": {
"version": "1.1.6", "version": "1.1.6",
"resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz",
@ -8936,11 +8898,6 @@
"pify": "^3.0.0" "pify": "^3.0.0"
} }
}, },
"make-error": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
"integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g=="
},
"map-age-cleaner": { "map-age-cleaner": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz",
@ -9542,54 +9499,16 @@
} }
}, },
"ms-rest-js": { "ms-rest-js": {
"version": "0.2.8", "version": "1.0.1",
"resolved": "http://registry.npmjs.org/ms-rest-js/-/ms-rest-js-0.2.8.tgz", "resolved": "https://registry.npmjs.org/ms-rest-js/-/ms-rest-js-1.0.1.tgz",
"integrity": "sha512-KgiSsbJzKcPLx0Zaca5PEdGOwm8X4Np+aTukK6stMl2eAqSrHvncjteyeXi6v6O0ECLYeUWVbqcPJfpw1PjnZQ==", "integrity": "sha512-o2Gms3XE4sCKm0FZLJicq0aa2ybYyV8pwUHKHJG1QExkk/csM7PLuHiaPAj6Xn3kzqzAx4cAYtyEp4P1T3ujyA==",
"requires": { "requires": {
"@types/form-data": "^2.2.1", "axios": "^0.18.0",
"@types/is-stream": "^1.1.0",
"@types/node": "^9.4.6",
"@types/node-fetch": "^1.6.7",
"@types/uuid": "^3.4.3",
"fetch-cookie": "^0.7.0",
"fetch-ponyfill": "github:amarzavery/fetch-ponyfill#136e6f8192bdb2aa0b7983f0b3b4361c357be9db",
"form-data": "^2.3.2", "form-data": "^2.3.2",
"is-buffer": "^2.0.0", "tough-cookie": "^2.4.3",
"is-stream": "^1.1.0", "tslib": "^1.9.2",
"moment": "^2.21.0", "uuid": "^3.2.1",
"url-parse": "^1.2.0", "xml2js": "^0.4.19"
"uuid": "^3.2.1"
},
"dependencies": {
"@types/node": {
"version": "9.6.35",
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.35.tgz",
"integrity": "sha512-h5zvHS8wXHGa+Gcqs9K8vqCgOtqjr0+NqG/DDJmQIX1wpR9HivAfgV8bjcD3mGM4bPfQw5Aneb2Pn8355L83jA=="
},
"fetch-ponyfill": {
"version": "github:amarzavery/fetch-ponyfill#136e6f8192bdb2aa0b7983f0b3b4361c357be9db",
"from": "github:amarzavery/fetch-ponyfill#136e6f8192bdb2aa0b7983f0b3b4361c357be9db",
"requires": {
"fetch-cookie": "~0.6.0",
"node-fetch": "~1.7.1"
},
"dependencies": {
"fetch-cookie": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/fetch-cookie/-/fetch-cookie-0.6.0.tgz",
"integrity": "sha1-T+xOQIzAAH9sBOVTYYr0s97jf2k=",
"requires": {
"es6-denodeify": "^0.1.1",
"tough-cookie": "^2.3.1"
}
}
}
},
"is-buffer": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz",
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw=="
}
} }
}, },
"mstranslator": { "mstranslator": {
@ -14821,11 +14740,6 @@
"resolved": "https://registry.npmjs.org/propagate/-/propagate-1.0.0.tgz", "resolved": "https://registry.npmjs.org/propagate/-/propagate-1.0.0.tgz",
"integrity": "sha1-AMLa7t2iDofjeCs0Stuhzd1q1wk=" "integrity": "sha1-AMLa7t2iDofjeCs0Stuhzd1q1wk="
}, },
"proto-list": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz",
"integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk="
},
"protocols": { "protocols": {
"version": "1.4.6", "version": "1.4.6",
"resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.6.tgz", "resolved": "https://registry.npmjs.org/protocols/-/protocols-1.4.6.tgz",
@ -16178,11 +16092,6 @@
} }
} }
}, },
"sigmund": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",
"integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA="
},
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
@ -16524,6 +16433,7 @@
"version": "0.5.10", "version": "0.5.10",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.10.tgz", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.10.tgz",
"integrity": "sha512-YfQ3tQFTK/yzlGJuX8pTwa4tifQj4QS2Mj7UegOu8jAz59MqIiMGPXxQhVQiIMNzayuUSF/jEuVnfFF5JqybmQ==", "integrity": "sha512-YfQ3tQFTK/yzlGJuX8pTwa4tifQj4QS2Mj7UegOu8jAz59MqIiMGPXxQhVQiIMNzayuUSF/jEuVnfFF5JqybmQ==",
"dev": true,
"requires": { "requires": {
"buffer-from": "^1.0.0", "buffer-from": "^1.0.0",
"source-map": "^0.6.0" "source-map": "^0.6.0"
@ -16532,7 +16442,8 @@
"source-map": { "source-map": {
"version": "0.6.1", "version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
} }
} }
}, },
@ -17609,73 +17520,11 @@
"semver": "^5.0.1" "semver": "^5.0.1"
} }
}, },
"ts-node": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.0.2.tgz",
"integrity": "sha512-MosTrinKmaAcWgO8tqMjMJB22h+sp3Rd1i4fdoWY4mhBDekOwIAKI/bzmRi7IcbCmjquccYg2gcF6NBkLgr0Tw==",
"requires": {
"arg": "^4.1.0",
"diff": "^3.1.0",
"make-error": "^1.1.1",
"source-map-support": "^0.5.6",
"yn": "^3.0.0"
}
},
"tslib": { "tslib": {
"version": "1.9.3", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha1-1+TdeSRdhUKMTX5IIqeZF5VMooY=" "integrity": "sha1-1+TdeSRdhUKMTX5IIqeZF5VMooY="
}, },
"tslint": {
"version": "5.13.0",
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.13.0.tgz",
"integrity": "sha512-ECOOQRxXCYnUUePG5h/+Z1Zouobk3KFpIHA9aKBB/nnMxs97S1JJPDGt5J4cGm1y9U9VmVlfboOxA8n1kSNzGw==",
"dev": true,
"requires": {
"babel-code-frame": "^6.22.0",
"builtin-modules": "^1.1.1",
"chalk": "^2.3.0",
"commander": "^2.12.1",
"diff": "^3.2.0",
"glob": "^7.1.1",
"js-yaml": "^3.7.0",
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"resolve": "^1.3.2",
"semver": "^5.3.0",
"tslib": "^1.8.0",
"tsutils": "^2.27.2"
}
},
"tslint-microsoft-contrib": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-6.0.0.tgz",
"integrity": "sha512-R//efwn+34IUjTJeYgNDAJdzG0jyLWIehygPt/PHuZAieTolFVS56FgeFW7DOLap9ghXzMiFPTmDgm54qaL7QA==",
"dev": true,
"requires": {
"tsutils": "^2.27.2 <2.29.0"
},
"dependencies": {
"tsutils": {
"version": "2.28.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.28.0.tgz",
"integrity": "sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
}
}
},
"tsutils": {
"version": "2.29.0",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
"integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
"dev": true,
"requires": {
"tslib": "^1.8.1"
}
},
"tunnel": { "tunnel": {
"version": "0.0.5", "version": "0.0.5",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.5.tgz", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.5.tgz",
@ -18039,9 +17888,9 @@
"integrity": "sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo=" "integrity": "sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo="
}, },
"url-parse": { "url-parse": {
"version": "1.4.3", "version": "1.4.4",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.3.tgz", "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.4.tgz",
"integrity": "sha1-v67kVciJAjIZ11fgRfpqaE7DbBU=", "integrity": "sha512-/92DTTorg4JjktLNLe6GPS2/RvAd/RGr6LuktmWSMLEOa6rjnlrFXNgSbSmkNvCoL2T028A0a1JaJLzRMlFoHg==",
"requires": { "requires": {
"querystringify": "^2.0.0", "querystringify": "^2.0.0",
"requires-port": "^1.0.0" "requires-port": "^1.0.0"
@ -18210,11 +18059,6 @@
} }
} }
}, },
"whatwg-fetch": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz",
"integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q=="
},
"whatwg-mimetype": { "whatwg-mimetype": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz",
@ -18733,11 +18577,6 @@
} }
} }
} }
},
"yn": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/yn/-/yn-3.0.0.tgz",
"integrity": "sha512-+Wo/p5VRfxUgBUGy2j/6KX2mj9AYJWOHuhMjMcbBFc3y54o9/4buK1ksBvuiK01C3kby8DH9lSmJdSxw+4G/2Q=="
} }
} }
} }

View file

@ -47,7 +47,7 @@
"commit": "git-cz" "commit": "git-cz"
}, },
"dependencies": { "dependencies": {
"@microsoft/microsoft-graph-client": "1.4.0", "@microsoft/microsoft-graph-client": "1.5.2",
"@semantic-release/exec": "^3.3.2", "@semantic-release/exec": "^3.3.2",
"adal-node": "0.1.28", "adal-node": "0.1.28",
"async": "2.6.2", "async": "2.6.2",
@ -59,30 +59,31 @@
"azure-arm-website": "5.7.0", "azure-arm-website": "5.7.0",
"bluebird": "^3.5.3", "bluebird": "^3.5.3",
"body-parser": "1.18.3", "body-parser": "1.18.3",
"botbuilder": "4.1.7", "botbuilder": "4.3.2",
"botbuilder-ai": "4.2.0", "botbuilder-ai": "4.3.2",
"botbuilder-azure": "4.2.0", "botbuilder-azure": "4.3.2",
"botbuilder-choices": "4.0.0-preview1.2", "botbuilder-choices": "4.0.0-preview1.2",
"botbuilder-dialogs": "4.2.0", "botbuilder-dialogs": "4.3.2",
"botbuilder-prompts": "4.0.0-preview1.2", "botbuilder-prompts": "4.0.0-preview1.2",
"botlib": "^0.1.21", "botlib": "^0.1.21",
"chai": "4.2.0", "chai": "4.2.0",
"child_process": "^1.0.2", "child_process": "^1.0.2",
"chokidar": "2.1.2", "chokidar": "2.1.2",
"cli-spinner": "^0.2.8", "cli-spinner": "^0.2.10",
"csv-parse": "4.3.3", "csv-parse": "4.3.3",
"dotenv-extended": "2.3.0", "dotenv-extended": "2.4.0",
"express": "4.16.4", "express": "4.16.4",
"express-promise-router": "3.0.3", "express-promise-router": "3.0.3",
"fs-extra": "7.0.1", "fs-extra": "7.0.1",
"ip": "^1.1.5", "ip": "^1.1.5",
"js-beautify": "^1.8.9", "js-beautify": "^1.9.0",
"localize": "0.4.7", "localize": "0.4.7",
"marked": "0.6.1", "marked": "0.6.1",
"mocha": "6.0.2", "mocha": "6.0.2",
"mocha-typescript": "1.1.17", "mocha-typescript": "1.1.17",
"ms": "2.1.1", "ms": "2.1.1",
"ms-rest-azure": "2.6.0", "ms-rest-azure": "2.6.0",
"ms-rest-js": "^1.0.1",
"nexmo": "2.4.1", "nexmo": "2.4.1",
"ngrok": "3.1.1", "ngrok": "3.1.1",
"nyc": "13.3.0", "nyc": "13.3.0",
@ -94,7 +95,7 @@
"request-promise": "4.2.4", "request-promise": "4.2.4",
"request-promise-native": "1.0.7", "request-promise-native": "1.0.7",
"scanf": "^1.0.2", "scanf": "^1.0.2",
"sequelize": "4.42.1", "sequelize": "4.43.0",
"sequelize-typescript": "0.6.7", "sequelize-typescript": "0.6.7",
"shx": "0.3.2", "shx": "0.3.2",
"simple-git": "1.107.0", "simple-git": "1.107.0",
@ -103,7 +104,7 @@
"swagger-client": "3.8.25", "swagger-client": "3.8.25",
"tedious": "5.0.3", "tedious": "5.0.3",
"temperature-js": "^0.1.0", "temperature-js": "^0.1.0",
"ts-node": "8.0.2", "ts-node": "8.0.3",
"typedoc": "0.14.2", "typedoc": "0.14.2",
"typedoc-plugin-external-module-name": "^2.0.0", "typedoc-plugin-external-module-name": "^2.0.0",
"typedoc-plugin-markdown": "^1.1.27", "typedoc-plugin-markdown": "^1.1.27",
@ -123,7 +124,7 @@
"@semantic-release/release-notes-generator": "^7.1.4", "@semantic-release/release-notes-generator": "^7.1.4",
"@types/chai": "4.1.7", "@types/chai": "4.1.7",
"@types/mocha": "5.2.6", "@types/mocha": "5.2.6",
"@types/sequelize": "4.27.38", "@types/sequelize": "4.27.39",
"@types/url-join": "4.0.0", "@types/url-join": "4.0.0",
"@types/winston": "2.4.4", "@types/winston": "2.4.4",
"ban-sensitive-files": "1.9.2", "ban-sensitive-files": "1.9.2",
@ -141,8 +142,8 @@
"standard": "12.0.1", "standard": "12.0.1",
"travis-deploy-once": "5.0.11", "travis-deploy-once": "5.0.11",
"ts-loader": "^5.3.3", "ts-loader": "^5.3.3",
"tslint": "^5.13.0", "tslint": "^5.13.1",
"tslint-microsoft-contrib": "^6.0.0" "tslint-microsoft-contrib": "^6.1.0"
}, },
"eslintConfig": { "eslintConfig": {
"env": { "env": {

View file

@ -36,24 +36,20 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join');
import { BotAdapter } from 'botbuilder';
import { WaterfallDialog } from 'botbuilder-dialogs'; import { WaterfallDialog } from 'botbuilder-dialogs';
import { GBMinInstance, IGBDialog } from 'botlib'; import { GBMinInstance, IGBDialog } from 'botlib';
import UrlJoin = require('url-join');
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService'; import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
import { GBConfigService } from '../../core.gbapp/services/GBConfigService'; import { GBConfigService } from '../../core.gbapp/services/GBConfigService';
import { GBDeployer } from '../../core.gbapp/services/GBDeployer'; import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
import { GBImporter } from '../../core.gbapp/services/GBImporterService'; import { GBImporter } from '../../core.gbapp/services/GBImporterService';
import { GBAdminService } from '../services/GBAdminService';
import { Messages } from '../strings'; import { Messages } from '../strings';
/** /**
* Dialogs for administration tasks. * Dialogs for administration tasks.
*/ */
export class AdminDialog extends IGBDialog { export class AdminDialog extends IGBDialog {
public static async createFarmCommand(text: any, min: GBMinInstance) {} public static async undeployPamand(text: any, min: GBMinInstance) {
public static async undeployPackageCommand(text: any, min: GBMinInstance) {
const packageName = text.split(' ')[1]; const packageName = text.split(' ')[1];
const importer = new GBImporter(min.core); const importer = new GBImporter(min.core);
const deployer = new GBDeployer(min.core, importer); const deployer = new GBDeployer(min.core, importer);
@ -71,34 +67,27 @@ export class AdminDialog extends IGBDialog {
await deployer.deployFromSharePoint(min.instance.instanceId, packageName); await deployer.deployFromSharePoint(min.instance.instanceId, packageName);
} else { } else {
const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH'); const additionalPath = GBConfigService.get('ADDITIONAL_DEPLOY_PATH');
if (!additionalPath) { if (additionalPath !== undefined) {
throw new Error('ADDITIONAL_DEPLOY_PATH is not set and deployPackage was called.'); throw new Error('ADDITIONAL_DEPLOY_PATH is not set and deployPackage was called.');
} }
await deployer.deployPackageFromLocalPath(min, UrlJoin(additionalPath, packageName)); await deployer.deployPackageFromLocalPath(min, UrlJoin(additionalPath, packageName));
} }
} }
public static async rebuildIndexPackageCommand(min: GBMinInstance, text: string, deployer: GBDeployer) { public static async rebuildIndexPackageCommand(min: GBMinInstance, deployer: GBDeployer) {
await deployer.rebuildIndex( await deployer.rebuildIndex(
min.instance, min.instance,
new AzureDeployerService(deployer).getKBSearchSchema(min.instance.searchIndex) new AzureDeployerService(deployer).getKBSearchSchema(min.instance.searchIndex)
); );
} }
public static async addConnectionCommand(min: GBMinInstance, text: any) {
const packageName = text.split(' ')[1];
const importer = new GBImporter(min.core);
const admin = new GBAdminService(min.core);
// TODO: await admin.addConnection
}
/** /**
* Setup dialogs flows and define services call. * Setup dialogs flows and define services call.
* *
* @param bot The bot adapter. * @param bot The bot adapter.
* @param min The minimal bot instance data. * @param min The minimal bot instance data.
*/ */
public static setup(bot: BotAdapter, min: GBMinInstance) { public static setup(min: GBMinInstance) {
// Setup services. // Setup services.
const importer = new GBImporter(min.core); const importer = new GBImporter(min.core);
@ -116,9 +105,9 @@ export class AdminDialog extends IGBDialog {
}, },
async step => { async step => {
const locale = step.context.activity.locale; const locale = step.context.activity.locale;
const password = step.result; const sensitive = step.result;
if (password === GBConfigService.get('ADMIN_PASS')) { if (sensitive === GBConfigService.get('ADMIN_PASS')) {
await step.context.sendActivity(Messages[locale].welcome); await step.context.sendActivity(Messages[locale].welcome);
return await step.prompt('textPrompt', Messages[locale].which_task); return await step.prompt('textPrompt', Messages[locale].which_task);
@ -129,8 +118,9 @@ export class AdminDialog extends IGBDialog {
} }
}, },
async step => { async step => {
const locale = step.context.activity.locale; const locale: string = step.context.activity.locale;
const text = step.result; // tslint:disable-next-line:no-unsafe-any
const text: string = step.result;
const cmdName = text.split(' ')[0]; const cmdName = text.split(' ')[0];
step.context.sendActivity(Messages[locale].working(cmdName)); step.context.sendActivity(Messages[locale].working(cmdName));
@ -138,29 +128,16 @@ export class AdminDialog extends IGBDialog {
if (text === 'quit') { if (text === 'quit') {
return await step.replaceDialog('/'); return await step.replaceDialog('/');
} else if (cmdName === 'createFarm') {
await AdminDialog.createFarmCommand(text, min);
return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'deployPackage') { } else if (cmdName === 'deployPackage') {
await AdminDialog.deployPackageCommand(min, text, deployer); await AdminDialog.deployPackageCommand(min, text, deployer);
return await step.replaceDialog('/admin', { firstRun: false }); return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'redeployPackage') { } else if (cmdName === 'redeployPackage') {
await AdminDialog.undeployPackageCommand(text, min);
await AdminDialog.deployPackageCommand(min, text, deployer); await AdminDialog.deployPackageCommand(min, text, deployer);
return await step.replaceDialog('/admin', { firstRun: false }); return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'rebuildIndex') { } else if (cmdName === 'rebuildIndex') {
await AdminDialog.rebuildIndexPackageCommand(min, text, deployer); await AdminDialog.rebuildIndexPackageCommand(min, deployer);
return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'addConnection') {
await AdminDialog.addConnectionCommand(min, text);
return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'undeployPackage') {
await AdminDialog.undeployPackageCommand(text, min);
return await step.replaceDialog('/admin', { firstRun: false }); return await step.replaceDialog('/admin', { firstRun: false });
} else if (cmdName === 'setupSecurity') { } else if (cmdName === 'setupSecurity') {
@ -224,9 +201,9 @@ export class AdminDialog extends IGBDialog {
); );
const locale = step.context.activity.locale; const locale = step.context.activity.locale;
const state = `${min.instance.instanceId}${Math.floor(Math.random() * 1000000000)}`; const state = `${min.instance.instanceId}${crypto.getRandomValues(new Uint32Array(16))[0]}`;
await min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state); min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state);
const url = `https://login.microsoftonline.com/${ const url = `https://login.microsoftonline.com/${
min.instance.authenticatorTenant min.instance.authenticatorTenant

View file

@ -38,9 +38,9 @@
import { AuthenticationContext, TokenResponse } from 'adal-node'; import { AuthenticationContext, TokenResponse } from 'adal-node';
import { IGBAdminService, IGBCoreService } from 'botlib'; import { IGBAdminService, IGBCoreService } from 'botlib';
import UrlJoin = require('url-join');
import { GuaribasInstance } from '../../core.gbapp/models/GBModel'; import { GuaribasInstance } from '../../core.gbapp/models/GBModel';
import { GuaribasAdmin } from '../models/AdminModel'; import { GuaribasAdmin } from '../models/AdminModel';
const UrlJoin = require('url-join');
const msRestAzure = require('ms-rest-azure'); const msRestAzure = require('ms-rest-azure');
const PasswordGenerator = require('strict-password-generator').default; const PasswordGenerator = require('strict-password-generator').default;
@ -65,15 +65,13 @@ export class GBAdminService implements IGBAdminService {
public static async getADALTokenFromUsername(username: string, password: string) { public static async getADALTokenFromUsername(username: string, password: string) {
const credentials = await GBAdminService.getADALCredentialsFromUsername(username, password); const credentials = await GBAdminService.getADALCredentialsFromUsername(username, password);
const accessToken = credentials.tokenCache._entries[0].accessToken;
return accessToken; return credentials.tokenCache._entries[0].accessToken;
} }
public static async getADALCredentialsFromUsername(username: string, password: string) { public static async getADALCredentialsFromUsername(username: string, password: string) {
const credentials = await msRestAzure.loginWithUsernamePassword(username, password);
return credentials; return await msRestAzure.loginWithUsernamePassword(username, password);
} }
public static getRndPassword(): string { public static getRndPassword(): string {
@ -102,9 +100,8 @@ export class GBAdminService implements IGBAdminService {
minimumLength: 12, minimumLength: 12,
maximumLength: 14 maximumLength: 14
}; };
const name = passwordGenerator.generatePassword(options);
return name; return passwordGenerator.generatePassword(options);
} }
public async setValue(instanceId: number, key: string, value: string) { public async setValue(instanceId: number, key: string, value: string) {
@ -170,7 +167,7 @@ export class GBAdminService implements IGBAdminService {
instance.authenticatorClientSecret, instance.authenticatorClientSecret,
resource, resource,
async (err, res) => { async (err, res) => {
if (err) { if (err !== undefined) {
reject(err); reject(err);
} else { } else {
const token = res as TokenResponse; const token = res as TokenResponse;

View file

@ -36,18 +36,30 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import { GBDialogStep, GBMinInstance, IGBCoreService, IGBPackage, GBLog } from 'botlib';
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
/**
* .gblib Package handler.
*/
export class GBAnalyticsPackage implements IGBPackage { export class GBAnalyticsPackage implements IGBPackage {
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {} public getDialogs(min: GBMinInstance) {
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {} GBLog.verbose(`getDialogs called.`);
public unloadPackage(core: IGBCoreService): void {} }
public loadBot(min: GBMinInstance): void {} public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
public unloadBot(min: GBMinInstance): void {} GBLog.verbose(`loadPackage called.`);
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {} }
public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`);
}
public loadBot(min: GBMinInstance): void {
GBLog.verbose(`loadBot called.`);
}
public unloadBot(min: GBMinInstance): void {
GBLog.verbose(`unloadBot called.`);
}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {
GBLog.verbose(`onNewSession called.`);
}
} }

View file

@ -1,69 +0,0 @@
/*****************************************************************************\
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ |
| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) |
| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' |
| | | ( )_) | |
| (_) \___/' |
| |
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
| Licensed under the AGPL-3.0. |
| |
| According to our dual licensing model, this program can be used either |
| under the terms of the GNU Affero General Public License, version 3, |
| or under a proprietary license. |
| |
| The texts of the GNU Affero General Public License with an additional |
| permission and of our proprietary license can be found at and |
| in the LICENSE file you have received along with this program. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU Affero General Public License for more details. |
| |
| "General Bots" is a registered trademark of Pragmatismo.io. |
| The licensing of the program under the AGPLv3 does not imply a |
| trademark license. Therefore any rights, title and interest in |
| our trademarks remain entirely with us. |
| |
\*****************************************************************************/
/**
* @fileoverview General Bots server core.
*/
'use strict';
import { BotAdapter } from 'botbuilder';
import { GBMinInstance } from 'botlib';
import { IGBDialog } from 'botlib';
import { WaterfallDialog } from 'botlib/node_modules/botbuilder-dialogs';
import { Messages } from '../strings';
export class BotFarmDialog extends IGBDialog {
/**
* Setup dialogs flows and define services call.
*
* @param bot The bot adapter.
* @param min The minimal bot instance data.
*/
public static setup(bot: BotAdapter, min: GBMinInstance) {
min.dialogs.add(new WaterfallDialog ('/createBotFarm', [
async step => {
const locale = step.context.activity.locale;
await step.prompt('choicePrompt', Messages[locale].what_about_me);
return step.next();
},
async step => {
const locale = step.context.activity.locale;
await step.context.sendActivity(Messages[locale].thanks);
return step.next();
}
]));
}
}

View file

@ -36,8 +36,7 @@
'use strict'; 'use strict';
import { IGBInstance } from 'botlib'; import { GBLog, IGBInstallationDeployer, IGBInstance } from 'botlib';
import { IGBInstallationDeployer } from 'botlib';
import * as fs from 'fs'; import * as fs from 'fs';
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService'; import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService'; import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
@ -47,7 +46,6 @@ const scanf = require('scanf');
* Handles command-line dialog for getting info for Boot Bot. * Handles command-line dialog for getting info for Boot Bot.
*/ */
export class StartDialog { export class StartDialog {
public static async createBaseInstance(installationDeployer: IGBInstallationDeployer) { public static async createBaseInstance(installationDeployer: IGBInstallationDeployer) {
// No .env so asks for cloud credentials to start a new farm. // No .env so asks for cloud credentials to start a new farm.
@ -122,7 +120,7 @@ export class StartDialog {
private static retrieveUsername() { private static retrieveUsername() {
let value = GBConfigService.get('CLOUD_USERNAME'); let value = GBConfigService.get('CLOUD_USERNAME');
if (!value) { if (value !== undefined) {
process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_USERNAME:`); process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_USERNAME:`);
value = scanf('%s').replace(/(\n|\r)+$/, ''); value = scanf('%s').replace(/(\n|\r)+$/, '');
} }
@ -132,7 +130,7 @@ export class StartDialog {
private static retrievePassword() { private static retrievePassword() {
let password = GBConfigService.get('CLOUD_PASSWORD'); let password = GBConfigService.get('CLOUD_PASSWORD');
if (!password) { if (password !== undefined) {
process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_PASSWORD:`); process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_PASSWORD:`);
password = scanf('%s').replace(/(\n|\r)+$/, ''); password = scanf('%s').replace(/(\n|\r)+$/, '');
} }
@ -142,16 +140,13 @@ export class StartDialog {
private static retrieveBotId() { private static retrieveBotId() {
let botId = GBConfigService.get('BOT_ID'); let botId = GBConfigService.get('BOT_ID');
if (!botId) { if (botId !== undefined) {
process.stdout.write( process.stdout.write(
`${GBAdminService.GB_PROMPT}Choose a unique bot Id containing lowercase letters, digits or `${GBAdminService.GB_PROMPT}Choose a unique bot Id containing lowercase letters, digits or
dashes (cannot use dash as the first two or last one characters), dashes (cannot use dash as the first two or last one characters),
cannot start or end with or contain consecutive dashes and having 4 to 42 characters long.\n` cannot start or end with or contain consecutive dashes and having 4 to 42 characters long.\n`
); );
process.stdout.write(`${GBAdminService.GB_PROMPT}BOT_ID:`); process.stdout.write(`${GBAdminService.GB_PROMPT}BOT_ID:`);
// TODO: Update this regexp to match description of it.
botId = scanf('%s').replace(/(\n|\r)+$/, ''); botId = scanf('%s').replace(/(\n|\r)+$/, '');
} }
@ -160,7 +155,7 @@ cannot start or end with or contain consecutive dashes and having 4 to 42 charac
private static retrieveAuthoringKey() { private static retrieveAuthoringKey() {
let authoringKey = GBConfigService.get('NLP_AUTHORING_KEY'); let authoringKey = GBConfigService.get('NLP_AUTHORING_KEY');
if (!authoringKey) { if (authoringKey !== undefined) {
process.stdout.write( process.stdout.write(
`${ `${
GBAdminService.GB_PROMPT GBAdminService.GB_PROMPT
@ -184,7 +179,7 @@ cannot start or end with or contain consecutive dashes and having 4 to 42 charac
please go to https://apps.dev.microsoft.com/portal/register-app to please go to https://apps.dev.microsoft.com/portal/register-app to
generate manually an App ID and App Secret.\n` generate manually an App ID and App Secret.\n`
); );
if (!appId) { if (appId !== undefined) {
process.stdout.write('Generated Application Id (MARKETPLACE_ID):'); process.stdout.write('Generated Application Id (MARKETPLACE_ID):');
appId = scanf('%s').replace(/(\n|\r)+$/, ''); appId = scanf('%s').replace(/(\n|\r)+$/, '');
} }
@ -194,7 +189,7 @@ generate manually an App ID and App Secret.\n`
private static retrieveAppPassword() { private static retrieveAppPassword() {
let appPassword = GBConfigService.get('MARKETPLACE_SECRET'); let appPassword = GBConfigService.get('MARKETPLACE_SECRET');
if (!appPassword) { if (appPassword !== undefined) {
process.stdout.write('Generated Password (MARKETPLACE_SECRET):'); process.stdout.write('Generated Password (MARKETPLACE_SECRET):');
appPassword = scanf('%s').replace(/(\n|\r)+$/, ''); appPassword = scanf('%s').replace(/(\n|\r)+$/, '');
} }
@ -207,7 +202,7 @@ generate manually an App ID and App Secret.\n`
const map = {}; const map = {};
let index = 1; let index = 1;
list.forEach(element => { list.forEach(element => {
console.log(`${index}: ${element.displayName} (${element.subscriptionId})`); GBLog.info(`${index}: ${element.displayName} (${element.subscriptionId})`);
map[index++] = element; map[index++] = element;
}); });
let subscriptionIndex; let subscriptionIndex;
@ -222,8 +217,8 @@ generate manually an App ID and App Secret.\n`
private static retrieveLocation() { private static retrieveLocation() {
let location = GBConfigService.get('CLOUD_LOCATION'); let location = GBConfigService.get('CLOUD_LOCATION');
if (!location) { if (location !== undefined) {
process.stdout.write('CLOUD_LOCATION (eg. \'westus\'):'); process.stdout.write('CLOUD_LOCATION (eg. westus):');
location = scanf('%s'); location = scanf('%s');
} }

View file

@ -36,19 +36,27 @@
'use strict'; 'use strict';
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib'; import { GBMinInstance, IGBCoreService, IGBPackage, GBLog, GBDialogStep } from 'botlib';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
export class GBAzureDeployerPackage implements IGBPackage { export class GBAzureDeployerPackage implements IGBPackage {
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {} public getDialogs(min: GBMinInstance) {
GBLog.verbose(`getDialogs called.`);
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {} }
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
public unloadPackage(core: IGBCoreService): void {} GBLog.verbose(`loadPackage called.`);
}
public loadBot(min: GBMinInstance): void {} public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`);
public unloadBot(min: GBMinInstance): void {} }
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {} public loadBot(min: GBMinInstance): void {
GBLog.verbose(`loadBot called.`);
}
public unloadBot(min: GBMinInstance): void {
GBLog.verbose(`unloadBot called.`);
}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {
GBLog.verbose(`onNewSession called.`);
}
} }

View file

@ -37,14 +37,14 @@
'use strict'; 'use strict';
import { CognitiveServicesManagementClient } from 'azure-arm-cognitiveservices'; import { CognitiveServicesManagementClient } from 'azure-arm-cognitiveservices';
import { CognitiveServicesAccount } from 'azure-arm-cognitiveservices/lib/models';
import { ResourceManagementClient, SubscriptionClient } from 'azure-arm-resource'; import { ResourceManagementClient, SubscriptionClient } from 'azure-arm-resource';
import { SearchManagementClient } from 'azure-arm-search'; import { SearchManagementClient } from 'azure-arm-search';
import { SqlManagementClient } from 'azure-arm-sql'; import { SqlManagementClient } from 'azure-arm-sql';
import { WebSiteManagementClient } from 'azure-arm-website'; import { WebSiteManagementClient } from 'azure-arm-website';
//tslint:disable-next-line:no-submodule-imports
import { AppServicePlan } from 'azure-arm-website/lib/models'; import { AppServicePlan } from 'azure-arm-website/lib/models';
import { IGBInstallationDeployer, IGBInstance } from 'botlib'; import { GBLog, IGBInstallationDeployer, IGBInstance } from 'botlib';
import { HttpMethods, ServiceClient, WebResource } from 'ms-rest-js'; import { HttpHeaders, HttpMethods, ServiceClient, WebResource } from 'ms-rest-js';
import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService'; import { GBAdminService } from '../../../packages/admin.gbapp/services/GBAdminService';
import { GBCorePackage } from '../../../packages/core.gbapp'; import { GBCorePackage } from '../../../packages/core.gbapp';
import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService'; import { GBConfigService } from '../../../packages/core.gbapp/services/GBConfigService';
@ -52,10 +52,15 @@ import { GBDeployer } from '../../../packages/core.gbapp/services/GBDeployer';
const Spinner = require('cli-spinner').Spinner; const Spinner = require('cli-spinner').Spinner;
const UrlJoin = require('url-join'); // tslint:disable-next-line:no-submodule-imports
import { CognitiveServicesAccount } from 'azure-arm-cognitiveservices/lib/models';
import UrlJoin = require('url-join');
const iconUrl = 'https://github.com/pragmatismo-io/BotServer/blob/master/docs/images/generalbots-logo-squared.png'; const iconUrl = 'https://github.com/pragmatismo-io/BotServer/blob/master/docs/images/generalbots-logo-squared.png';
const publicIp = require('public-ip'); const publicIp = require('public-ip');
/**
* Deployer for Microsoft cloud.
*/
export class AzureDeployerService implements IGBInstallationDeployer { export class AzureDeployerService implements IGBInstallationDeployer {
public apiVersion = '2017-12-01'; public apiVersion = '2017-12-01';
public defaultEndPoint = 'http://localhost:4242'; public defaultEndPoint = 'http://localhost:4242';
@ -81,10 +86,10 @@ export class AzureDeployerService implements IGBInstallationDeployer {
const req = new WebResource(); const req = new WebResource();
req.method = verb; req.method = verb;
req.url = url; req.url = url;
req.headers = {}; req.headers = <HttpHeaders>{};
req.headers['Content-Type'] = 'application/json'; req.headers['Content-Type'] = 'application/json';
req.headers['accept-language'] = '*'; req.headers['accept-language'] = '*';
req.headers.Authorization = 'Bearer ' + accessToken; req.headers['Authorization'] = `Bearer ${accessToken}`;
req.body = body; req.body = body;
return req; return req;
@ -192,8 +197,8 @@ export class AzureDeployerService implements IGBInstallationDeployer {
} }
], ],
scoringProfiles: [], scoringProfiles: [],
defaultScoringProfile: null, defaultScoringProfile: undefined,
corsOptions: null corsOptions: undefined
}; };
} }
@ -218,7 +223,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
const url = UrlJoin(baseUrl, query); const url = UrlJoin(baseUrl, query);
const req = AzureDeployerService.createRequestObject(url, accessToken, 'PATCH', JSON.stringify(parameters)); const req = AzureDeployerService.createRequestObject(url, accessToken, 'PATCH', JSON.stringify(parameters));
const res = await httpClient.sendRequest(req); const res = await httpClient.sendRequest(req);
if (!(res.bodyAsJson as any).id) { if (!(res['bodyAsJson'] as any).id) {
throw res.bodyAsText; throw res.bodyAsText;
} }
GBLog.info(`Bot proxy updated at: ${endpoint}.`); GBLog.info(`Bot proxy updated at: ${endpoint}.`);
@ -250,11 +255,9 @@ export class AzureDeployerService implements IGBInstallationDeployer {
const culture = 'en-us'; const culture = 'en-us';
this.initServices(credentials, subscriptionId); this.initServices(credentials, subscriptionId);
const spinner = new Spinner('%s'); const spinner = new Spinner('%s');
spinner.start(); spinner.start();
spinner.setSpinnerString('|/-\\'); spinner.setSpinnerString('|/-\\');
let keys: any; let keys: any;
const name = instance.botId; const name = instance.botId;
@ -313,8 +316,6 @@ export class AzureDeployerService implements IGBInstallationDeployer {
instance.textAnalyticsEndpoint = textAnalytics.endpoint; instance.textAnalyticsEndpoint = textAnalytics.endpoint;
instance.textAnalyticsKey = keys.key1; instance.textAnalyticsKey = keys.key1;
// TODO: Check quotes being added when NLP field is filled.
GBLog.info(`Deploying NLP...`); GBLog.info(`Deploying NLP...`);
const nlp = await this.createNLP(name, `${name}-nlp`, instance.cloudLocation); const nlp = await this.createNLP(name, `${name}-nlp`, instance.cloudLocation);
keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name); keys = await this.cognitiveClient.accounts.listKeys(name, nlp.name);
@ -358,7 +359,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
appPassword: string, appPassword: string,
subscriptionId: string subscriptionId: string
) { ) {
const instance = <IGBInstance> {}; const instance = <IGBInstance>{};
instance.botId = title; instance.botId = title;
instance.cloudUsername = username; instance.cloudUsername = username;
@ -371,10 +372,9 @@ export class AzureDeployerService implements IGBInstallationDeployer {
instance.adminPass = GBAdminService.getRndPassword(); instance.adminPass = GBAdminService.getRndPassword();
const credentials = await GBAdminService.getADALCredentialsFromUsername(username, password); const credentials = await GBAdminService.getADALCredentialsFromUsername(username, password);
this.deployFarm(`http://${instance.botId}.azurewebsites.net`, instance, credentials, subscriptionId); // tslint:disable-next-line:no-http-string
const url = `http://${instance.botId}.azurewebsites.net`;
// TODO: Copy github to webapp. this.deployFarm(url, instance, credentials, subscriptionId);
//const status = await git.status();
} }
private initServices(credentials: any, subscriptionId: string) { private initServices(credentials: any, subscriptionId: string) {
@ -398,21 +398,16 @@ export class AzureDeployerService implements IGBInstallationDeployer {
} }
private async registerProviders(subscriptionId, baseUrl, accessToken) { private async registerProviders(subscriptionId, baseUrl, accessToken) {
const query = `subscriptions/${subscriptionId}/providers/${ const query = `subscriptions/${subscriptionId}/providers/${this.provider}/register?api-version=2018-02-01`;
this.provider
}/register?api-version=2018-02-01`;
const requestUrl = UrlJoin(baseUrl, query); const requestUrl = UrlJoin(baseUrl, query);
const req = new WebResource(); const req = new WebResource();
req.method = 'POST'; req.method = 'POST';
req.url = requestUrl; req.url = requestUrl;
req.headers = {}; req.headers = <HttpHeaders>{};
req.headers['Content-Type'] = 'application/json; charset=utf-8'; req.headers['Content-Type'] = 'application/json; charset=utf-8';
req.headers['accept-language'] = '*'; req.headers['accept-language'] = '*';
req.headers.Authorization = 'Bearer ' + accessToken; req.headers['Authorization'] = `Bearer ${accessToken}`;
const httpClient = new ServiceClient();
// TODO: Check res for error.
} }
/** /**
@ -469,7 +464,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
let url = UrlJoin(baseUrl, query); let url = UrlJoin(baseUrl, query);
let req = AzureDeployerService.createRequestObject(url, accessToken, 'PUT', JSON.stringify(parameters)); let req = AzureDeployerService.createRequestObject(url, accessToken, 'PUT', JSON.stringify(parameters));
const res = await httpClient.sendRequest(req); const res = await httpClient.sendRequest(req);
if (!(res.bodyAsJson as any).id) { if (!(res['bodyAsJson'] as any).id) {
reject(res.bodyAsText); reject(res.bodyAsText);
return; return;
@ -477,13 +472,14 @@ export class AzureDeployerService implements IGBInstallationDeployer {
setTimeout(async () => { setTimeout(async () => {
try { try {
//tslint:disable-next-line:max-line-length
query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/Microsoft.BotService/botServices/${botId}/channels/WebChatChannel/listChannelWithKeys?api-version=${ query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/Microsoft.BotService/botServices/${botId}/channels/WebChatChannel/listChannelWithKeys?api-version=${
this.apiVersion this.apiVersion
}`; }`;
url = UrlJoin(baseUrl, query); url = UrlJoin(baseUrl, query);
req = AzureDeployerService.createRequestObject(url, accessToken, 'GET', JSON.stringify(parameters)); req = AzureDeployerService.createRequestObject(url, accessToken, 'GET', JSON.stringify(parameters));
const resChannel = await httpClient.sendRequest(req); const resChannel = await httpClient.sendRequest(req);
const key = (resChannel.bodyAsJson as any).properties.properties.sites[0].key; const key = (resChannel['bodyAsJson'] as any).properties.properties.sites[0].key;
instance.webchatKey = key; instance.webchatKey = key;
resolve(instance); resolve(instance);
} catch (error) { } catch (error) {
@ -507,8 +503,8 @@ export class AzureDeployerService implements IGBInstallationDeployer {
}; };
const body = JSON.stringify(parameters); const body = JSON.stringify(parameters);
const apps = await this.makeNlpRequest(location, authoringKey, null, 'GET', 'apps'); const apps = await this.makeNlpRequest(location, authoringKey, undefined, 'GET', 'apps');
const app = (apps.bodyAsJson as any).filter(x => x.name == name)[0]; const app = (apps['bodyAsJson'] as any).filter(x => x.name === name)[0];
let id: string; let id: string;
if (!app) { if (!app) {
const res = await this.makeNlpRequest(location, authoringKey, body, 'POST', 'apps'); const res = await this.makeNlpRequest(location, authoringKey, body, 'POST', 'apps');
@ -530,7 +526,7 @@ export class AzureDeployerService implements IGBInstallationDeployer {
const req = new WebResource(); const req = new WebResource();
req.method = method; req.method = method;
req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/${resource}`; req.url = `https://${location}.api.cognitive.microsoft.com/luis/api/v2.0/${resource}`;
req.headers = {}; req.headers = <HttpHeaders> {};
req.headers['Content-Type'] = 'application/json'; req.headers['Content-Type'] = 'application/json';
req.headers['accept-language'] = '*'; req.headers['accept-language'] = '*';
req.headers['Ocp-Apim-Subscription-Key'] = authoringKey; req.headers['Ocp-Apim-Subscription-Key'] = authoringKey;

View file

@ -36,28 +36,33 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib'; import { GBMinInstance, IGBCoreService, IGBPackage, GBLog, GBDialogStep } from 'botlib';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
import { ConsoleDirectLine } from './services/ConsoleDirectLine'; import { ConsoleDirectLine } from './services/ConsoleDirectLine';
export class GBConsolePackage implements IGBPackage { export class GBConsolePackage implements IGBPackage {
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public channel: ConsoleDirectLine; public channel: ConsoleDirectLine;
public getDialogs(min: GBMinInstance) {} public getDialogs(min: GBMinInstance) {
GBLog.verbose(`getDialogs called.`);
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {} }
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
public unloadPackage(core: IGBCoreService): void {} GBLog.verbose(`loadPackage called.`);
}
public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`);
}
public unloadBot(min: GBMinInstance): void {
GBLog.verbose(`unloadBot called.`);
}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {
GBLog.verbose(`onNewSession called.`);
}
public loadBot(min: GBMinInstance): void { public loadBot(min: GBMinInstance): void {
this.channel = new ConsoleDirectLine(min.instance.webchatKey); this.channel = new ConsoleDirectLine(min.instance.webchatKey);
} }
public unloadBot(min: GBMinInstance): void {}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {}
} }

View file

@ -1,50 +1,58 @@
const Swagger = require('swagger-client'); const Swagger = require('swagger-client');
const rp = require('request-promise'); const rp = require('request-promise');
import { GBService } from 'botlib'; import { GBLog, GBService } from 'botlib';
/**
* Bot simulator in terminal window.
*/
export class ConsoleDirectLine extends GBService { export class ConsoleDirectLine extends GBService {
public pollInterval = 1000; public pollInterval: number = 1000;
public directLineSecret = ''; public directLineSecret: string = '';
public directLineClientName = 'DirectLineClient'; public directLineClientName: string = 'DirectLineClient';
public directLineSpecUrl = 'https://docs.botframework.com/en-us/restapi/directline3/swagger.json'; public directLineSpecUrl: string = 'https://docs.botframework.com/en-us/restapi/directline3/swagger.json';
constructor(directLineSecret) { constructor(directLineSecret: string) {
super(); super();
this.directLineSecret = directLineSecret; this.directLineSecret = directLineSecret;
// tslint:disable-next-line:no-unsafe-any
const directLineClient = rp(this.directLineSpecUrl) const directLineClient = rp(this.directLineSpecUrl)
.then(function(spec) { .then((spec: string) => {
// tslint:disable-next-line:no-unsafe-any
return new Swagger({ return new Swagger({
spec: JSON.parse(spec.trim()), spec: JSON.parse(spec.trim()),
usePromise: true usePromise: true
}); });
}) })
.then(function(client) { .then(client => {
// tslint:disable-next-line:no-unsafe-any
client.clientAuthorizations.add( client.clientAuthorizations.add(
'AuthorizationBotConnector', 'AuthorizationBotConnector',
new Swagger.ApiKeyAuthorization('Authorization', 'Bearer ' + directLineSecret, 'header') // tslint:disable-next-line:no-unsafe-any
new Swagger.ApiKeyAuthorization('Authorization', `Bearer ${directLineSecret}`, 'header')
); );
return client; return client;
}) })
.catch(function(err) { .catch(err => {
console.error('Error initializing DirectLine client', err); GBLog.error(`Error initializing DirectLine client ${err}`);
}); });
// TODO: Remove *this* issue.
const _this_ = this; const _this_ = this;
// tslint:disable-next-line:no-unsafe-any
directLineClient.then(client => { directLineClient.then(client => {
// tslint:disable-next-line:no-unsafe-any
client.Conversations.Conversations_StartConversation() client.Conversations.Conversations_StartConversation()
.then(function(response) { .then(response => {
// tslint:disable-next-line:no-unsafe-any
return response.obj.conversationId; return response.obj.conversationId;
}) })
.then(function(conversationId) { .then(conversationId => {
_this_.sendMessagesFromConsole(client, conversationId); _this_.sendMessagesFromConsole(client, conversationId);
_this_.pollMessages(client, conversationId); _this_.pollMessages(client, conversationId);
}) })
.catch(function(err) { .catch(err => {
console.error('Error starting conversation', err); GBLog.error(`Error starting conversation ${err}`);
}); });
}); });
} }
@ -54,14 +62,16 @@ export class ConsoleDirectLine extends GBService {
process.stdin.resume(); process.stdin.resume();
const stdin = process.stdin; const stdin = process.stdin;
process.stdout.write('Command> '); process.stdout.write('Command> ');
stdin.addListener('data', function(e) { stdin.addListener('data', e => {
const input = e.toString().trim(); // tslint:disable-next-line:no-unsafe-any
if (input) { const input: string = e.toString().trim();
if (input !== undefined) {
// exit // exit
if (input.toLowerCase() === 'exit') { if (input.toLowerCase() === 'exit') {
return process.exit(); return process.exit();
} }
// tslint:disable-next-line:no-unsafe-any
client.Conversations.Conversations_PostActivity({ client.Conversations.Conversations_PostActivity({
conversationId: conversationId, conversationId: conversationId,
activity: { activity: {
@ -73,8 +83,8 @@ export class ConsoleDirectLine extends GBService {
name: _this_.directLineClientName name: _this_.directLineClientName
} }
} }
}).catch(function(err) { }).catch(err => {
console.error('Error sending message:', err); GBLog.error(`Error sending message: ${err}`);
}); });
process.stdout.write('Command> '); process.stdout.write('Command> ');
@ -82,71 +92,85 @@ export class ConsoleDirectLine extends GBService {
}); });
} }
/** TBD: Poll Messages from conversation using DirectLine client */
public pollMessages(client, conversationId) { public pollMessages(client, conversationId) {
const _this_ = this; const _this_ = this;
console.log('Starting polling message for conversationId: ' + conversationId); GBLog.info(`Starting polling message for conversationId: ${conversationId}`);
let watermark = null; let watermark;
setInterval(function() { setInterval(() => {
// tslint:disable-next-line:no-unsafe-any
client.Conversations.Conversations_GetActivities({ conversationId: conversationId, watermark: watermark }) client.Conversations.Conversations_GetActivities({ conversationId: conversationId, watermark: watermark })
.then(function(response) { .then(response => {
// tslint:disable-next-line:no-unsafe-any
watermark = response.obj.watermark; watermark = response.obj.watermark;
// tslint:disable-next-line:no-unsafe-any
return response.obj.activities; return response.obj.activities;
}) })
.then(_this_.printMessages, _this_.directLineClientName); .then(_this_.printMessages, _this_.directLineClientName);
// tslint:disable-next-line:align
}, this.pollInterval); }, this.pollInterval);
} }
// tslint:disable:no-unsafe-any
public printMessages(activities, directLineClientName) { public printMessages(activities, directLineClientName) {
if (activities && activities.length) { if (activities && activities.length) {
// ignore own messages // ignore own messages
activities = activities.filter(function(m) { activities = activities.filter(m => {
return m.from.id !== directLineClientName; return m.from.id !== directLineClientName;
}); });
if (activities.length) { if (activities.length) {
// print other messages // print other messages
activities.forEach(activity => { activities.forEach(activity => {
console.log(activity.text); GBLog.info(activity.text);
// tslint:disable-next-line:align
}, this); }, this);
process.stdout.write('Command> '); process.stdout.write('Command> ');
} }
} }
} }
// tslint:enable:no-unsafe-any
// tslint:disable:no-unsafe-any
public printMessage(activity) { public printMessage(activity) {
if (activity.text) { if (activity.text) {
console.log(activity.text); GBLog.info(activity.text);
} }
if (activity.attachments) { if (activity.attachments) {
activity.attachments.forEach(function(attachment) { activity.attachments.forEach(attachment => {
switch (attachment.contentType) { switch (attachment.contentType) {
case 'application/vnd.microsoft.card.hero': case 'application/vnd.microsoft.card.hero':
this.renderHeroCard(attachment); this.renderHeroCard(attachment);
break; break;
case 'image/png': case 'image/png':
console.log('Opening the requested image ' + attachment.contentUrl); GBLog.info(`Opening the requested image ${attachment.contentUrl}`);
open(attachment.contentUrl); open(attachment.contentUrl);
break; break;
default:
GBLog.info(`Unknown contentType: ${attachment.contentType}`);
break;
} }
}); });
} }
} }
// tslint:enable:no-unsafe-any
// tslint:disable:no-unsafe-any
public renderHeroCard(attachment) { public renderHeroCard(attachment) {
const width = 70; const width = 70;
const contentLine = function(content) { const contentLine = content => {
return ' '.repeat((width - content.length) / 2) + content + ' '.repeat((width - content.length) / 2); return `${' '.repeat((width - content.length) / 2)}content${' '.repeat((width - content.length) / 2)}`;
}; };
console.log('/' + '*'.repeat(width + 1)); GBLog.info(`/${'*'.repeat(width + 1)}`);
console.log('*' + contentLine(attachment.content.title) + '*'); GBLog.info(`*${contentLine(attachment.content.title)}*`);
console.log('*' + ' '.repeat(width) + '*'); GBLog.info(`*${' '.repeat(width)}*`);
console.log('*' + contentLine(attachment.content.text) + '*'); GBLog.info(`*${contentLine(attachment.content.text)}*`);
console.log('*'.repeat(width + 1) + '/'); GBLog.info(`${'*'.repeat(width + 1)}/`);
} }
// tslint:enable:no-unsafe-any
} }

View file

@ -36,9 +36,9 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import { GBMinInstance, IGBPackage } from 'botlib'; import { GBMinInstance, IGBPackage, GBLog, GBDialogStep } from 'botlib';
import { IGBCoreService } from 'botlib'; import { IGBCoreService } from 'botlib';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
@ -49,19 +49,25 @@ import { GuaribasChannel, GuaribasException, GuaribasInstance, GuaribasPackage }
export class GBCorePackage implements IGBPackage { export class GBCorePackage implements IGBPackage {
public static CurrentEngineName = 'guaribas-1.0.0'; public static CurrentEngineName = 'guaribas-1.0.0';
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {}
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void { public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
core.sequelize.addModels([GuaribasInstance, GuaribasPackage, GuaribasChannel, GuaribasException]); core.sequelize.addModels([GuaribasInstance, GuaribasPackage, GuaribasChannel, GuaribasException]);
} }
public unloadPackage(core: IGBCoreService): void {} public getDialogs(min: GBMinInstance) {
GBLog.verbose(`getDialogs called.`);
}
public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`);
}
public unloadBot(min: GBMinInstance): void {
GBLog.verbose(`unloadBot called.`);
}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {
GBLog.verbose(`onNewSession called.`);
}
public loadBot(min: GBMinInstance): void { public loadBot(min: GBMinInstance): void {
WelcomeDialog.setup(min.bot, min); WelcomeDialog.setup(min.bot, min);
WhoAmIDialog.setup(min.bot, min); WhoAmIDialog.setup(min.bot, min);
} }
public unloadBot(min: GBMinInstance): void {}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {}
} }

View file

@ -34,12 +34,12 @@
import { TurnContext } from 'botbuilder'; import { TurnContext } from 'botbuilder';
import { WaterfallStepContext } from 'botbuilder-dialogs'; import { WaterfallStepContext } from 'botbuilder-dialogs';
import { GBMinInstance } from 'botlib'; import { GBLog, GBMinInstance } from 'botlib';
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
import UrlJoin = require('url-join');
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService'; import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService'; import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
import { GBDeployer } from './GBDeployer'; import { GBDeployer } from './GBDeployer';
const UrlJoin = require('url-join');
/** /**
* BASIC system class for extra manipulation of bot behaviour. * BASIC system class for extra manipulation of bot behaviour.
@ -64,14 +64,14 @@ class SysClass {
} }
public async createABotFarmUsing( public async createABotFarmUsing(
botId, botId: string,
username, username: string,
password, password: string,
location, location: string,
nlpAuthoringKey, nlpAuthoringKey: string,
appId, appId: string,
appPassword, appPassword: string,
subscriptionId subscriptionId: string
) { ) {
const service = new AzureDeployerService(this.deployer); const service = new AzureDeployerService(this.deployer);
await service.deployToCloud( await service.deployToCloud(
@ -91,7 +91,7 @@ class SysClass {
*/ */
public async sendEmail(to, subject, body) { public async sendEmail(to, subject, body) {
// tslint:disable-next-line:no-console // tslint:disable-next-line:no-console
console.log(`[E-mail]: to:${to}, subject: ${subject}, body: ${body}.`); GBLog.info(`[E-mail]: to:${to}, subject: ${subject}, body: ${body}.`);
} }
/** /**

View file

@ -30,8 +30,8 @@
| | | |
\*****************************************************************************/ \*****************************************************************************/
import * as fs from 'fs'; import * as fs from 'fs';
import { GBLog } from 'botlib';
/** /**
* @fileoverview General Bots server core. * @fileoverview General Bots server core.
@ -49,7 +49,7 @@ export class GBConfigService {
overrideProcessEnv: true overrideProcessEnv: true
}); });
} catch (e) { } catch (e) {
console.error(e.message); GBLog.error(e.message);
process.exit(3); process.exit(3);
} }
} }

View file

@ -63,7 +63,7 @@ export class GBConversationalService implements IGBConversationalService {
return step.context.activity.locale; return step.context.activity.locale;
} }
public async sendEvent(step: GBDialogStep, name: string, value: any): Promise<any> { public async sendEvent(step: GBDialogStep, name: string, value: Object): Promise<any> {
if (step.context.activity.channelId === 'webchat') { if (step.context.activity.channelId === 'webchat') {
const msg = MessageFactory.text(''); const msg = MessageFactory.text('');
msg.value = value; msg.value = value;

View file

@ -36,16 +36,15 @@
'use strict'; 'use strict';
const Path = require('path'); const Path = require('path');
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
const Fs = require('fs'); const Fs = require('fs');
const WaitUntil = require('wait-until'); const WaitUntil = require('wait-until');
const express = require('express'); const express = require('express');
const child_process = require('child_process'); const child_process = require('child_process');
const graph = require('@microsoft/microsoft-graph-client'); const graph = require('@microsoft/microsoft-graph-client');
import { GBMinInstance, IGBCoreService, IGBInstance } from 'botlib'; import { GBMinInstance, IGBCoreService, IGBInstance, GBLog } from 'botlib';
import { GBError, IGBPackage } from 'botlib'; import { GBError, IGBPackage } from 'botlib';
import { AzureSearch } from 'pragmatismo-io-framework'; import { AzureSearch } from 'pragmatismo-io-framework';
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService'; import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';

View file

@ -36,10 +36,10 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join');
import { IGBCoreService, IGBInstance } from 'botlib'; import { IGBCoreService, IGBInstance } from 'botlib';
import fs = require('fs'); import fs = require('fs');
import path = require('path'); import path = require('path');
import UrlJoin = require('url-join');
import { SecService } from '../../security.gblib/services/SecService'; import { SecService } from '../../security.gblib/services/SecService';
import { GuaribasInstance } from '../models/GBModel'; import { GuaribasInstance } from '../models/GBModel';

View file

@ -37,7 +37,7 @@
'use strict'; 'use strict';
const { DialogSet, TextPrompt } = require('botbuilder-dialogs'); const { DialogSet, TextPrompt } = require('botbuilder-dialogs');
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
const express = require('express'); const express = require('express');
const request = require('request-promise-native'); const request = require('request-promise-native');

View file

@ -41,11 +41,11 @@ import { TSCompiler } from './TSCompiler';
const walkPromise = require('walk-promise'); const walkPromise = require('walk-promise');
const vm = require('vm'); const vm = require('vm');
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import DialogClass from './GBAPIService';
const vb2ts = require('vbscript-to-typescript/dist/converter'); const vb2ts = require('vbscript-to-typescript/dist/converter');
const beautify = require('js-beautify').js; const beautify = require('js-beautify').js;
/** /**
* @fileoverview Virtualization services for emulation of BASIC. * @fileoverview Virtualization services for emulation of BASIC.
* This alpha version is using a hack in form of converter to * This alpha version is using a hack in form of converter to
@ -249,7 +249,7 @@ export class GBVMService extends GBService {
min.dialogs.add( min.dialogs.add(
new WaterfallDialog('/hear', [ new WaterfallDialog('/hear', [
async step => { async step => {
step.activeDialog.state.cbId = step.options.id; step.activeDialog.state.cbId = step.options['id'];
return await step.prompt('textPrompt', {}); return await step.prompt('textPrompt', {});
}, },
@ -259,7 +259,7 @@ export class GBVMService extends GBService {
const cbId = step.activeDialog.state.cbId; const cbId = step.activeDialog.state.cbId;
const cb = min.cbMap[cbId]; const cb = min.cbMap[cbId];
cb.bind({ step: step: GBDialogStep, context: step.context }); // TODO: Necessary or min.sandbox? cb.bind({ step: step, context: step.context }); // TODO: Necessary or min.sandbox?
await step.endDialog(); await step.endDialog();

View file

@ -38,7 +38,6 @@
import * as ts from 'typescript'; import * as ts from 'typescript';
export class TSCompiler { export class TSCompiler {
private static shouldIgnoreError(diagnostic) { private static shouldIgnoreError(diagnostic) {

View file

@ -86,7 +86,7 @@ export class FeedbackDialog extends IGBDialog {
const locale = step.context.activity.locale; const locale = step.context.activity.locale;
await step.context.sendActivity(Messages[locale].about_suggestions); await step.context.sendActivity(Messages[locale].about_suggestions);
step.activeDialog.state.cbId = step.options['id']; step.activeDialog.state.cbId = step.options.id;
return await step.prompt('textPrompt', Messages[locale].what_about_service); return await step.prompt('textPrompt', Messages[locale].what_about_service);
}, },

View file

@ -44,7 +44,6 @@ import { GBMinInstance } from 'botlib';
import { CSService } from '../services/CSService'; import { CSService } from '../services/CSService';
import { Messages } from '../strings'; import { Messages } from '../strings';
export class QualityDialog extends IGBDialog { export class QualityDialog extends IGBDialog {
/** /**
* Setup dialogs flows and define services call. * Setup dialogs flows and define services call.

View file

@ -36,8 +36,8 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import { GBMinInstance, IGBCoreService, IGBPackage, GBLog, GBDialogStep } from 'botlib';
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib'; import UrlJoin = require('url-join');
import { FeedbackDialog } from './dialogs/FeedbackDialog'; import { FeedbackDialog } from './dialogs/FeedbackDialog';
import { QualityDialog } from './dialogs/QualityDialog'; import { QualityDialog } from './dialogs/QualityDialog';
import { GuaribasQuestionAlternate } from './models/index'; import { GuaribasQuestionAlternate } from './models/index';
@ -46,16 +46,24 @@ import { Sequelize } from 'sequelize-typescript';
export class GBCustomerSatisfactionPackage implements IGBPackage { export class GBCustomerSatisfactionPackage implements IGBPackage {
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {} public getDialogs(min: GBMinInstance) {
GBLog.verbose(`getDialogs called.`);
}
public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`);
}
public unloadBot(min: GBMinInstance): void {
GBLog.verbose(`unloadBot called.`);
}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {
GBLog.verbose(`onNewSession called.`);
}
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void { public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
core.sequelize.addModels([GuaribasQuestionAlternate]); core.sequelize.addModels([GuaribasQuestionAlternate]);
} }
public unloadPackage(core: IGBCoreService): void {}
public loadBot(min: GBMinInstance): void { public loadBot(min: GBMinInstance): void {
FeedbackDialog.setup(min.bot, min); FeedbackDialog.setup(min.bot, min);
QualityDialog.setup(min.bot, min); QualityDialog.setup(min.bot, min);
} }
public unloadBot(min: GBMinInstance): void {}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {}
} }

View file

@ -38,14 +38,12 @@
import { BotAdapter } from 'botbuilder'; import { BotAdapter } from 'botbuilder';
import { WaterfallDialog } from 'botbuilder-dialogs'; import { WaterfallDialog } from 'botbuilder-dialogs';
import { IGBDialog } from 'botlib'; import { IGBDialog, GBLog } from 'botlib';
import { GBMinInstance } from 'botlib'; import { GBMinInstance } from 'botlib';
import { AzureText } from 'pragmatismo-io-framework'; import { AzureText } from 'pragmatismo-io-framework';
import { Messages } from '../strings'; import { Messages } from '../strings';
import { KBService } from './../services/KBService'; import { KBService } from './../services/KBService';
export class AskDialog extends IGBDialog { export class AskDialog extends IGBDialog {
/** /**
* Setup dialogs flows and define services call. * Setup dialogs flows and define services call.
@ -59,13 +57,13 @@ export class AskDialog extends IGBDialog {
min.dialogs.add( min.dialogs.add(
new WaterfallDialog('/answerEvent', [ new WaterfallDialog('/answerEvent', [
async step => { async step => {
if (step.options && step.options.questionId) { if (step.options && step.options['questionId']) {
const question = await service.getQuestionById(min.instance.instanceId, step.options.questionId); const question = await service.getQuestionById(min.instance.instanceId, step.options['questionId']);
const answer = await service.getAnswerById(min.instance.instanceId, question.answerId); const answer = await service.getAnswerById(min.instance.instanceId, question.answerId);
// Sends the answer to all outputs, including projector. // Sends the answer to all outputs, including projector.
await service.sendAnswer(min.conversationalService, step: GBDialogStep, answer); await service.sendAnswer(min.conversationalService, step, answer);
await step.replaceDialog('/ask', { isReturning: true }); await step.replaceDialog('/ask', { isReturning: true });
} }
@ -79,7 +77,7 @@ export class AskDialog extends IGBDialog {
new WaterfallDialog('/answer', [ new WaterfallDialog('/answer', [
async step => { async step => {
const user = await min.userProfile.get(step.context, {}); const user = await min.userProfile.get(step.context, {});
let text = step.options.query; let text = step.options['query'];
if (!text) { if (!text) {
throw new Error(`/answer being called with no args query text.`); throw new Error(`/answer being called with no args query text.`);
} }
@ -88,13 +86,13 @@ export class AskDialog extends IGBDialog {
// Stops any content on projector. // Stops any content on projector.
await min.conversationalService.sendEvent(step: GBDialogStep, 'stop', null); await min.conversationalService.sendEvent(step, 'stop', null);
// Handle extra text from FAQ. // Handle extra text from FAQ.
if (step.options && step.options.query) { if (step.options && step.options['query']) {
text = step.options.query; text = step.options['query'];
} else if (step.options && step.options.fromFaq) { } else if (step.options && step.options['fromFaq']) {
await step.context.sendActivity(Messages[locale].going_answer); await step.context.sendActivity(Messages[locale].going_answer);
} }
@ -126,7 +124,7 @@ export class AskDialog extends IGBDialog {
// Sends the answer to all outputs, including projector. // Sends the answer to all outputs, including projector.
await service.sendAnswer(min.conversationalService, step: GBDialogStep, resultsA.answer); await service.sendAnswer(min.conversationalService, step, resultsA.answer);
// Goes to ask loop, again. // Goes to ask loop, again.
@ -155,11 +153,11 @@ export class AskDialog extends IGBDialog {
// Sends the answer to all outputs, including projector. // Sends the answer to all outputs, including projector.
await service.sendAnswer(min.conversationalService, step: GBDialogStep, resultsB.answer); await service.sendAnswer(min.conversationalService, step, resultsB.answer);
return await step.replaceDialog('/ask', { isReturning: true }); return await step.replaceDialog('/ask', { isReturning: true });
} else { } else {
if (!(await min.conversationalService.routeNLP(step: GBDialogStep, min, text))) { if (!(await min.conversationalService.routeNLP(step, min, text))) {
await step.context.sendActivity(Messages[locale].did_not_find); await step.context.sendActivity(Messages[locale].did_not_find);
return await step.replaceDialog('/ask', { isReturning: true }); return await step.replaceDialog('/ask', { isReturning: true });
@ -183,9 +181,9 @@ export class AskDialog extends IGBDialog {
// Three forms of asking. // Three forms of asking.
if (step.options && step.options.firstTime) { if (step.options && step.options['firstTime'] ) {
text = Messages[locale].ask_first_time; text = Messages[locale].ask_first_time;
} else if (step.options && step.options.isReturning) { } else if (step.options && step.options['isReturning']) {
text = Messages[locale].anything_else; text = Messages[locale].anything_else;
} else if (user.subjects.length > 0) { } else if (user.subjects.length > 0) {
text = Messages[locale].which_question; text = Messages[locale].which_question;

View file

@ -37,7 +37,7 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder'; import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
import { WaterfallDialog } from 'botbuilder-dialogs'; import { WaterfallDialog } from 'botbuilder-dialogs';
@ -63,8 +63,8 @@ export class MenuDialog extends IGBDialog {
const locale = step.context.activity.locale; const locale = step.context.activity.locale;
let rootSubjectId = null; let rootSubjectId = null;
if (step.options && step.options.data) { if (step.options && step.options['data']) {
const subject = step.options.data; const subject = step.options ['data'];
// If there is a shortcut specified as subject destination, go there. // If there is a shortcut specified as subject destination, go there.
@ -89,7 +89,7 @@ export class MenuDialog extends IGBDialog {
'menu', 'menu',
user.subjects user.subjects
); );
await min.conversationalService.sendEvent(step: GBDialogStep, 'play', { await min.conversationalService.sendEvent(step, 'play', {
playerType: 'bullet', playerType: 'bullet',
data: data.slice(0, 10) data: data.slice(0, 10)
}); });

View file

@ -36,9 +36,9 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import { GBMinInstance, IGBPackage } from 'botlib'; import { GBDialogStep, GBLog, GBMinInstance, IGBPackage } from 'botlib';
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from './models/index'; import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from './models/index';
import { IGBCoreService } from 'botlib'; import { IGBCoreService } from 'botlib';
@ -49,17 +49,25 @@ import { MenuDialog } from './dialogs/MenuDialog';
export class GBKBPackage implements IGBPackage { export class GBKBPackage implements IGBPackage {
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {} public getDialogs(min: GBMinInstance) {
GBLog.verbose(`getDialogs called.`);
}
public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`);
}
public unloadBot(min: GBMinInstance): void {
GBLog.verbose(`unloadBot called.`);
}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {
GBLog.verbose(`onNewSession called.`);
}
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void { public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
core.sequelize.addModels([GuaribasAnswer, GuaribasQuestion, GuaribasSubject]); core.sequelize.addModels([GuaribasAnswer, GuaribasQuestion, GuaribasSubject]);
} }
public unloadPackage(core: IGBCoreService): void {}
public loadBot(min: GBMinInstance): void { public loadBot(min: GBMinInstance): void {
AskDialog.setup(min.bot, min); AskDialog.setup(min.bot, min);
FaqDialog.setup(min.bot, min); FaqDialog.setup(min.bot, min);
MenuDialog.setup(min.bot, min); MenuDialog.setup(min.bot, min);
} }
public unloadBot(min: GBMinInstance): void {}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {}
} }

View file

@ -34,32 +34,38 @@
* @fileoverview Knowledge base services and logic. * @fileoverview Knowledge base services and logic.
*/ */
const Path = require('path'); const Path = require('path');
const Fs = require('fs'); const Fs = require('fs');
import UrlJoin = require('url-join');
const parse = require('bluebird').promisify(require('csv-parse'));
const UrlJoin = require('url-join');
const marked = require('marked'); const marked = require('marked');
const path = require('path'); const path = require('path');
const asyncPromise = require('async-promises'); const asyncPromise = require('async-promises');
const walkPromise = require('walk-promise'); const walkPromise = require('walk-promise');
import { Messages } from '../strings'; // tslint:disable:no-unsafe-any
const parse = require('bluebird').promisify(require('csv-parse'));
// tslint:enable:no-unsafe-any
import { IGBConversationalService, IGBCoreService, IGBInstance } from 'botlib'; import { GBDialogStep, GBLog, IGBConversationalService, IGBCoreService, IGBInstance } from 'botlib';
import { AzureSearch } from 'pragmatismo-io-framework'; import { AzureSearch } from 'pragmatismo-io-framework';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService'; import { AzureDeployerService } from '../../azuredeployer.gbapp/services/AzureDeployerService';
import { GuaribasPackage } from '../../core.gbapp/models/GBModel'; import { GuaribasPackage } from '../../core.gbapp/models/GBModel';
import { GBDeployer } from '../../core.gbapp/services/GBDeployer'; import { GBDeployer } from '../../core.gbapp/services/GBDeployer';
import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from '../models'; import { GuaribasAnswer, GuaribasQuestion, GuaribasSubject } from '../models';
import { Messages } from '../strings';
import { GBConfigService } from './../../core.gbapp/services/GBConfigService'; import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
/**
* Result for quey on KB data.
*/
export class KBServiceSearchResults { export class KBServiceSearchResults {
public answer: GuaribasAnswer; public answer: GuaribasAnswer;
public questionId: number; public questionId: number;
} }
/**
* All services related to knowledge base management.
*/
export class KBService { export class KBService {
public sequelize: Sequelize; public sequelize: Sequelize;
@ -68,7 +74,7 @@ export class KBService {
} }
public static getFormattedSubjectItems(subjects: GuaribasSubject[]) { public static getFormattedSubjectItems(subjects: GuaribasSubject[]) {
if (!subjects) { if (subjects !== null) {
return ''; return '';
} }
const out = []; const out = [];
@ -116,7 +122,7 @@ export class KBService {
} }
}); });
if (question) { if (question !== null) {
const answer = await GuaribasAnswer.findOne({ const answer = await GuaribasAnswer.findOne({
where: { where: {
instanceId: instanceId, instanceId: instanceId,
@ -127,7 +133,7 @@ export class KBService {
return Promise.resolve({ question: question, answer: answer }); return Promise.resolve({ question: question, answer: answer });
} }
return Promise.resolve(null); return Promise.resolve(undefined);
} }
public async addAnswer(obj: GuaribasAnswer): Promise<GuaribasAnswer> { public async addAnswer(obj: GuaribasAnswer): Promise<GuaribasAnswer> {
@ -157,40 +163,39 @@ export class KBService {
query = query.replace('/', ' '); query = query.replace('/', ' ');
query = query.replace('\\', ' '); query = query.replace('\\', ' ');
if (subjects) { if (subjects !== null) {
const text = KBService.getSubjectItemsSeparatedBySpaces(subjects); const text = KBService.getSubjectItemsSeparatedBySpaces(subjects);
if (text) { if (text !== null) {
query = `${query} ${text}`; query = `${query} ${text}`;
} }
} }
query = `${query}&$filter=instanceId eq ${instance.instanceId}`; query = `${query}&$filter=instanceId eq ${instance.instanceId}`;
try {
if (instance.searchKey && GBConfigService.get('STORAGE_DIALECT') === 'mssql') { // tslint:disable:no-unsafe-any
const service = new AzureSearch( if (instance.searchKey !== null && GBConfigService.get('STORAGE_DIALECT') === 'mssql') {
instance.searchKey, const service = new AzureSearch(
instance.searchHost, instance.searchKey,
instance.searchIndex, instance.searchHost,
instance.searchIndexer instance.searchIndex,
); instance.searchIndexer
const results = await service.search(query); );
if (results && results.length > 0 && results[0]['@search.score'] >= searchScore) { const results = await service.search(query);
const value = await this.getAnswerById(instance.instanceId, results[0].answerId);
if (value) { if (results && results.length > 0 && results[0]['@search.score'] >= searchScore) {
return Promise.resolve({ answer: value, questionId: results[0].questionId }); const value = await this.getAnswerById(instance.instanceId, results[0].answerId);
} else { if (value !== null) {
return Promise.resolve({ answer: null, questionId: 0 }); return Promise.resolve({ answer: value, questionId: results[0].questionId });
}
}
} else {
const data = await this.getAnswerByText(instance.instanceId, query);
if (data) {
return Promise.resolve({ answer: data.answer, questionId: data.question.questionId });
} else { } else {
return Promise.resolve({ answer: null, questionId: 0 }); return Promise.resolve({ answer: undefined, questionId: 0 });
} }
} }
} catch (reason) { } else {
return Promise.reject(new Error(reason)); const data = await this.getAnswerByText(instance.instanceId, query);
if (data) {
return Promise.resolve({ answer: data.answer, questionId: data.question.questionId });
} else {
return Promise.resolve({ answer: undefined, questionId: 0 });
}
} }
} }
@ -203,14 +208,13 @@ export class KBService {
} }
public async getFaqBySubjectArray(from: string, subjects: any): Promise<GuaribasQuestion[]> { public async getFaqBySubjectArray(from: string, subjects: any): Promise<GuaribasQuestion[]> {
if (subjects) { if (subjects) {
const where = { const where = {
from: from, from: from,
subject1: null, subject1: undefined,
subject2: null, subject2: undefined,
subject3: null, subject3: undefined,
subject4: null subject4: undefined
}; };
if (subjects[0]) { if (subjects[0]) {
@ -291,13 +295,13 @@ export class KBService {
let indexer = 0; let indexer = 0;
subjectArray.forEach(element => { subjectArray.forEach(element => {
if (indexer == 0) { if (indexer === 0) {
subject1 = subjectArray[indexer].substring(0, 63); subject1 = subjectArray[indexer].substring(0, 63);
} else if (indexer == 1) { } else if (indexer === 1) {
subject2 = subjectArray[indexer].substring(0, 63); subject2 = subjectArray[indexer].substring(0, 63);
} else if (indexer == 2) { } else if (indexer === 2) {
subject3 = subjectArray[indexer].substring(0, 63); subject3 = subjectArray[indexer].substring(0, 63);
} else if (indexer == 3) { } else if (indexer === 3) {
subject4 = subjectArray[indexer].substring(0, 63); subject4 = subjectArray[indexer].substring(0, 63);
} }
indexer++; indexer++;
@ -310,7 +314,7 @@ export class KBService {
content: answer, content: answer,
format: format, format: format,
packageId: packageId, packageId: packageId,
prevId: lastQuestionId ? lastQuestionId : 0 prevId: lastQuestionId !== null ? lastQuestionId : 0
}); });
const question1 = await GuaribasQuestion.create({ const question1 = await GuaribasQuestion.create({
@ -326,7 +330,7 @@ export class KBService {
packageId: packageId packageId: packageId
}); });
if (lastAnswer && lastQuestionId) { if (lastAnswer !== null && lastQuestionId !== 0) {
await lastAnswer.update({ nextId: lastQuestionId }); await lastAnswer.update({ nextId: lastQuestionId });
} }
lastAnswer = answer1; lastAnswer = answer1;
@ -336,21 +340,21 @@ export class KBService {
} else { } else {
// Skips the header. // Skips the header.
return Promise.resolve(null); return Promise.resolve(undefined);
} }
}); });
} }
public async sendAnswer(conversationalService: IGBConversationalService, step: GBDialogStep, answer: GuaribasAnswer) { public async sendAnswer(conversationalService: IGBConversationalService, step: GBDialogStep, answer: GuaribasAnswer) {
if (answer.content.endsWith('.mp4')) { if (answer.content.endsWith('.mp4')) {
await conversationalService.sendEvent(step: GBDialogStep, 'play', { await conversationalService.sendEvent(step, 'play', {
playerType: 'video', playerType: 'video',
data: answer.content data: answer.content
}); });
} else if (answer.content.length > 140 && step.context._activity.channelId === 'webchat') { } else if (answer.content.length > 140 && step.context.activity.channelId === 'webchat') {
const locale = step.context.activity.locale; const locale = step.context.activity.locale;
await step.context.sendActivity(Messages[locale].will_answer_projector); // TODO: Handle rnd. await step.context.sendActivity(Messages[locale].will_answer_projector);
let html = answer.content; let html = answer.content;
if (answer.format === '.md') { if (answer.format === '.md') {
@ -367,7 +371,7 @@ export class KBService {
}); });
html = marked(answer.content); html = marked(answer.content);
} }
await conversationalService.sendEvent(step: GBDialogStep, 'play', { await conversationalService.sendEvent(step, 'play', {
playerType: 'markdown', playerType: 'markdown',
data: { data: {
content: html, content: html,
@ -378,7 +382,7 @@ export class KBService {
}); });
} else { } else {
await step.context.sendActivity(answer.content); await step.context.sendActivity(answer.content);
await conversationalService.sendEvent(step: GBDialogStep, 'stop', null); await conversationalService.sendEvent(step, 'stop', undefined);
} }
} }
@ -409,12 +413,10 @@ export class KBService {
} }
public async importSubjectFile(packageId: number, filename: string, instance: IGBInstance): Promise<any> { public async importSubjectFile(packageId: number, filename: string, instance: IGBInstance): Promise<any> {
const subjects = JSON.parse(Fs.readFileSync(filename, 'utf8')); const subjectsLoaded = JSON.parse(Fs.readFileSync(filename, 'utf8'));
const doIt = async (subjects: GuaribasSubject[], parentSubjectId: number) => { const doIt = async (subjects: GuaribasSubject[], parentSubjectId: number) => {
return asyncPromise.eachSeries(subjects, async item => { return asyncPromise.eachSeries(subjects, async item => {
const mediaFilename = item.id + '.png';
const value = await GuaribasSubject.create({ const value = await GuaribasSubject.create({
internalId: item.id, internalId: item.id,
parentSubjectId: parentSubjectId, parentSubjectId: parentSubjectId,
@ -434,7 +436,7 @@ export class KBService {
}); });
}; };
return doIt(subjects.children, null); return doIt(subjectsLoaded.children, undefined);
} }
public async undeployKbFromStorage(instance: IGBInstance, deployer: GBDeployer, packageId: number) { public async undeployKbFromStorage(instance: IGBInstance, deployer: GBDeployer, packageId: number) {

View file

@ -36,25 +36,32 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib'; import { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from './models'; import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from './models';
export class GBSecurityPackage implements IGBPackage { export class GBSecurityPackage implements IGBPackage {
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public getDialogs(min: GBMinInstance) {} public getDialogs(min: GBMinInstance) {
GBLog.verbose(`getDialogs called.`);
}
public unloadPackage(core: IGBCoreService): void {
GBLog.verbose(`unloadPackage called.`);
}
public loadBot(min: GBMinInstance): void {
GBLog.verbose(`loadBot called.`);
}
public unloadBot(min: GBMinInstance): void {
GBLog.verbose(`unloadBot called.`);
}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {
GBLog.verbose(`onNewSession called.`);
}
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void { public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {
core.sequelize.addModels([GuaribasGroup, GuaribasUser, GuaribasUserGroup]); core.sequelize.addModels([GuaribasGroup, GuaribasUser, GuaribasUserGroup]);
} }
public unloadPackage(core: IGBCoreService): void {}
public loadBot(min: GBMinInstance): void {}
public unloadBot(min: GBMinInstance): void {}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {}
} }

View file

@ -1,5 +1,5 @@
const Fs = require('fs'); const Fs = require('fs');
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import { GBService, IGBInstance } from 'botlib'; import { GBService, IGBInstance } from 'botlib';
import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models'; import { GuaribasGroup, GuaribasUser, GuaribasUserGroup } from '../models';

View file

@ -36,9 +36,9 @@
'use strict'; 'use strict';
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
import { GBMinInstance, IGBCoreService, IGBPackage } from 'botlib'; import { GBMinInstance, IGBCoreService, IGBPackage, GBLog, GBDialogStep } from 'botlib';
import { Sequelize } from 'sequelize-typescript'; import { Sequelize } from 'sequelize-typescript';
import { WhatsappDirectLine } from './services/WhatsappDirectLine'; import { WhatsappDirectLine } from './services/WhatsappDirectLine';
@ -47,11 +47,6 @@ export class GBWhatsappPackage implements IGBPackage {
public sysPackages: IGBPackage[] = undefined; public sysPackages: IGBPackage[] = undefined;
public channel: WhatsappDirectLine; public channel: WhatsappDirectLine;
public getDialogs(min: GBMinInstance) {}
public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {}
public unloadPackage(core: IGBCoreService): void {}
public loadBot(min: GBMinInstance): void { public loadBot(min: GBMinInstance): void {
// Only loads engine if it is defined on services.json. // Only loads engine if it is defined on services.json.
@ -68,6 +63,9 @@ export class GBWhatsappPackage implements IGBPackage {
} }
} }
public unloadBot(min: GBMinInstance): void {} public getDialogs(min: GBMinInstance) {GBLog.verbose (`getDialogs called.`);}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {} public loadPackage(core: IGBCoreService, sequelize: Sequelize): void {GBLog.verbose (`loadPackage called.`);}
public unloadPackage(core: IGBCoreService): void {GBLog.verbose (`unloadPackage called.`);}
public unloadBot(min: GBMinInstance): void {GBLog.verbose (`unloadBot called.`);}
public onNewSession(min: GBMinInstance, step: GBDialogStep): void {GBLog.verbose (`onNewSession called.`);}
} }

View file

@ -1,8 +1,8 @@
const UrlJoin = require('url-join'); import UrlJoin = require('url-join');
const Swagger = require('swagger-client'); const Swagger = require('swagger-client');
const rp = require('request-promise'); const rp = require('request-promise');
import { GBService } from 'botlib'; import { GBService, GBLog } from 'botlib';
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
export class WhatsappDirectLine extends GBService { export class WhatsappDirectLine extends GBService {
@ -67,13 +67,13 @@ export class WhatsappDirectLine extends GBService {
const result = await request.post(options); const result = await request.post(options);
GBLog.info(result); GBLog.info(result);
} catch (error) { } catch (error) {
GBLog.error('Error initializing 3rd party Whatsapp provider.', error); GBLog.error(`Error initializing 3rd party Whatsapp provider(1) ${error}`);
} }
return client; return client;
}) })
.catch(err => { .catch(err => {
GBLog.error('Error initializing DirectLine client', err); GBLog.error(`Error initializing 3rd party Whatsapp provider(2) ${err}`);
}); });
} }
@ -104,7 +104,7 @@ export class WhatsappDirectLine extends GBService {
this.pollMessages(client, conversationId, from, fromName); this.pollMessages(client, conversationId, from, fromName);
}) })
.catch(err => { .catch(err => {
console.error('Error starting conversation', err); GBLog.error(`Error starting conversation ${err}`);
}); });
} else { } else {
this.inputMessage(client, conversationId, text, from, fromName); this.inputMessage(client, conversationId, text, from, fromName);

View file

@ -12,6 +12,8 @@
"rulesDirectory": ["node_modules/tslint-microsoft-contrib"], "rulesDirectory": ["node_modules/tslint-microsoft-contrib"],
"jsRules": {}, "jsRules": {},
"rules": { "rules": {
"no-unsafe-any":false,
"newline-per-chained-call": false,
"no-floating-promises": false, "no-floating-promises": false,
"no-var-requires": false, "no-var-requires": false,
"typedef": false, "typedef": false,
@ -24,6 +26,7 @@
"no-redundant-jsdoc": false, "no-redundant-jsdoc": false,
"no-return-await": false, "no-return-await": false,
"prefer-type-cast": false, "prefer-type-cast": false,
"non-literal-fs-path": false,
"no-object-literal-type-assertion": false, "no-object-literal-type-assertion": false,
"no-increment-decrement": false, "no-increment-decrement": false,
"no-any": false, "no-any": false,