From ae73cf8528acd0cc2cef0b00c798b97344a517ad Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Wed, 21 Aug 2019 21:04:55 +0000 Subject: [PATCH] feat(sharepoint): SharePoint deployPackage added. --- package-lock.json | 301 ++++++++++++++++-- package.json | 4 +- packages/admin.gbapp/dialogs/AdminDialog.ts | 20 +- packages/core.gbapp/services/GBCoreService.ts | 7 +- packages/sharepoint.gblib/index.ts | 65 ++++ .../services/SharePointService.ts | 90 ++++++ packages/sharepoint.gblib/strings.ts | 8 + 7 files changed, 473 insertions(+), 22 deletions(-) create mode 100644 packages/sharepoint.gblib/index.ts create mode 100644 packages/sharepoint.gblib/services/SharePointService.ts create mode 100644 packages/sharepoint.gblib/strings.ts diff --git a/package-lock.json b/package-lock.json index bee38457..165fecda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1342,6 +1342,16 @@ "@types/node": "*" } }, + "@types/cookie": { + "version": "0.1.29", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.1.29.tgz", + "integrity": "sha1-kyRoBUXAx7HcbCWMtG8yt4R1s6w=" + }, + "@types/core-js": { + "version": "0.9.46", + "resolved": "https://registry.npmjs.org/@types/core-js/-/core-js-0.9.46.tgz", + "integrity": "sha512-LooLR6XHes9V+kNYRz1Qm8w3atw9QMn7XeZUmIpUelllF9BdryeUKd/u0Wh5ErcjpWfG39NrToU9MF7ngsTFVw==" + }, "@types/documentdb": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/@types/documentdb/-/documentdb-1.10.5.tgz", @@ -1481,6 +1491,15 @@ "@types/tough-cookie": "*" } }, + "@types/request-promise": { + "version": "4.1.44", + "resolved": "https://registry.npmjs.org/@types/request-promise/-/request-promise-4.1.44.tgz", + "integrity": "sha512-RId7eFsUKxfal1LirDDIcOp9u3MM3NXFDBcC3sqIMcmu7f4U6DsCEMD8RbLZtnPrQlN5Jc79di/WPsIEDO4keg==", + "requires": { + "@types/bluebird": "*", + "@types/request": "*" + } + }, "@types/request-promise-native": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/@types/request-promise-native/-/request-promise-native-1.0.16.tgz", @@ -1733,8 +1752,7 @@ "ansi-escapes": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", - "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", - "dev": true + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==" }, "ansi-parser": { "version": "3.2.9", @@ -2701,12 +2719,34 @@ "@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" + }, + "dependencies": { + "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" + } + } + } + } } }, "oauth-sign": { @@ -3001,12 +3041,34 @@ "@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" + }, + "dependencies": { + "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" + } + } + } + } } }, "oauth-sign": { @@ -3466,8 +3528,7 @@ "chardet": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" }, "chdir-promise": { "version": "0.6.2", @@ -3648,7 +3709,6 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, "requires": { "restore-cursor": "^2.0.0" } @@ -3732,8 +3792,7 @@ "cli-width": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", - "dev": true + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" }, "cliui": { "version": "4.1.0", @@ -4292,6 +4351,14 @@ "safe-buffer": "^5.0.1" } }, + "cpass": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/cpass/-/cpass-2.1.1.tgz", + "integrity": "sha512-834wWEDTA0FRsMRf7au7gFt5OtFlDLKJjruFd8RezOfWi/EVSg4ZOtoQ2pVW0YoN0lpe/erA9TVx24K5mAFU6g==", + "requires": { + "simple-encryptor": "^3.0.0" + } + }, "create-error-class": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", @@ -5111,6 +5178,11 @@ "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", "dev": true }, + "empty-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/empty-dir/-/empty-dir-2.0.0.tgz", + "integrity": "sha512-XAedXlNAQZxMmbllXY9cxuESlNVjZ8xd67bSIUZwbS7VoLyhlNehVN3Iy35yDTGFHKR1opBRgORkp3am0so+WQ==" + }, "enabled": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", @@ -6019,7 +6091,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", - "dev": true, "requires": { "chardet": "^0.7.0", "iconv-lite": "^0.4.24", @@ -6171,7 +6242,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, "requires": { "escape-string-regexp": "^1.0.5" } @@ -7244,6 +7314,27 @@ "sshpk": "^1.7.0" } }, + "httpntlm": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.7.6.tgz", + "integrity": "sha1-aZHoNSg2AH1nEBuD247Q+RX5BtA=", + "requires": { + "httpreq": ">=0.4.22", + "underscore": "~1.7.0" + }, + "dependencies": { + "underscore": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", + "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=" + } + } + }, + "httpreq": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", + "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=" + }, "https-proxy-agent": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", @@ -9343,8 +9434,7 @@ "mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=" }, "nan": { "version": "2.14.0", @@ -9561,6 +9651,15 @@ "integrity": "sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=", "dev": true }, + "node-ntlm-client": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/node-ntlm-client/-/node-ntlm-client-0.1.2.tgz", + "integrity": "sha1-bAXiNLDZGUuwh5kpSYxvE5YshHI=", + "requires": { + "extend": "^3.0.0", + "request": "^2.66.0" + } + }, "node-pre-gyp": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", @@ -9587,6 +9686,103 @@ "semver": "^5.3.0" } }, + "node-sp-auth": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/node-sp-auth/-/node-sp-auth-2.5.7.tgz", + "integrity": "sha512-quRxbJurLW9XIcG66VgwV8Xs4zpm98XdQphLO5dJ41mbMNEKqLHdp1oTjkeReSltwQ3UPtiiGzD+A439Pa1/cg==", + "requires": { + "@types/bluebird": "^3.5.8", + "@types/cookie": "^0.1.29", + "@types/core-js": "^0.9.34", + "@types/jsonwebtoken": "^7.2.3", + "@types/lodash": "^4.14.69", + "@types/node": "^6.0.45", + "@types/request": "^2.47.0", + "@types/request-promise": "^4.1.41", + "bluebird": "^3.4.6", + "cookie": "^0.3.1", + "cpass": "^2.0.0", + "jsonwebtoken": "^8.3.0", + "lodash": "^4.17.4", + "node-ntlm-client": "0.1.2", + "node-sp-auth-config": "^2.4.5", + "request": "^2.75.0", + "request-promise": "^4.1.1", + "xmldoc": "^0.5.1" + }, + "dependencies": { + "@types/node": { + "version": "6.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-6.14.7.tgz", + "integrity": "sha512-YbPXbaynBTe0pVExPhL76TsWnxSPeFAvImIsmylpBWn/yfw+lHy+Q68aawvZHsgskT44ZAoeE67GM5f+Brekew==" + }, + "jsonwebtoken": { + "version": "8.5.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz", + "integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==", + "requires": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^5.6.0" + } + } + } + }, + "node-sp-auth-config": { + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-sp-auth-config/-/node-sp-auth-config-2.6.7.tgz", + "integrity": "sha512-2Vap4Mlr3+2lCa7+f3xNVzmdrWDIo6XBkuKZeVyoIL6HKh0iW28Xxfvuw4D7VkL2lJdqKYh2uEK2pIL0YeVGVg==", + "requires": { + "colors": "^1.3.3", + "commander": "^2.20.0", + "cpass": "^2.1.1", + "inquirer": "~6.3.1", + "mkdirp": "^0.5.1", + "node-sp-auth": "^2.5.7" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "inquirer": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.3.1.tgz", + "integrity": "sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA==", + "requires": { + "ansi-escapes": "^3.2.0", + "chalk": "^2.4.2", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^2.0.0", + "lodash": "^4.17.11", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^6.4.0", + "string-width": "^2.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "nodesecurity-npm-utils": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/nodesecurity-npm-utils/-/nodesecurity-npm-utils-6.0.0.tgz", @@ -13191,7 +13387,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, "requires": { "mimic-fn": "^1.0.0" }, @@ -13199,8 +13394,7 @@ "mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" } } }, @@ -14514,7 +14708,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, "requires": { "onetime": "^2.0.0", "signal-exit": "^3.0.2" @@ -14563,7 +14756,6 @@ "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, "requires": { "is-promise": "^2.1.0" } @@ -14599,7 +14791,6 @@ "version": "6.5.2", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", - "dev": true, "requires": { "tslib": "^1.9.0" } @@ -14633,6 +14824,11 @@ "resolved": "https://registry.npmjs.org/scanf/-/scanf-1.0.2.tgz", "integrity": "sha512-3WTLRdIAypK0117Fqep8rXlUesYyz8kcMsC4ATSFO6tqGmxmzohFizIKOIrgKCs1b7RYR9QI6XOFrvH5ZGP/iA==" }, + "scmp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/scmp/-/scmp-2.0.0.tgz", + "integrity": "sha1-JHEQ7yLM+JexOj8KvdtSeCOTzWo=" + }, "sec": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/sec/-/sec-1.0.0.tgz", @@ -15192,6 +15388,14 @@ } } }, + "simple-encryptor": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/simple-encryptor/-/simple-encryptor-3.0.0.tgz", + "integrity": "sha512-xRgj9pU3Gfkl+6iBYRoXM4BdEwY4bLdL1W0tp7AjGTA7Hytv5iwmB5tvJh6K2iVszvPPYimQjLFV8jRZz3fJ1g==", + "requires": { + "scmp": "2.0.0" + } + }, "simple-git": { "version": "1.113.0", "resolved": "https://registry.npmjs.org/simple-git/-/simple-git-1.113.0.tgz", @@ -15406,6 +15610,41 @@ "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, + "sp-request": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/sp-request/-/sp-request-2.1.3.tgz", + "integrity": "sha512-FEzfPecH0J6K45tZXmHaP1MeqPtourNQu/ssJxZdRjCDRCElcXMsyIoZuQuyxuhabXU//wVPWJQcOJ0zuXzuTQ==", + "requires": { + "@types/bluebird": "^3.5.8", + "@types/core-js": "^0.9.34", + "@types/lodash": "^4.14.37", + "@types/node": "^6.0.45", + "@types/request": "0.0.31", + "@types/request-promise": "^4.1.36", + "bluebird": "^3.5.0", + "httpntlm": "^1.7.5", + "lodash": "^4.12.0", + "node-sp-auth": "^2.1.1", + "request": "^2.81.0", + "request-promise": "^4.2.1" + }, + "dependencies": { + "@types/node": { + "version": "6.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-6.14.7.tgz", + "integrity": "sha512-YbPXbaynBTe0pVExPhL76TsWnxSPeFAvImIsmylpBWn/yfw+lHy+Q68aawvZHsgskT44ZAoeE67GM5f+Brekew==" + }, + "@types/request": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/@types/request/-/request-0.0.31.tgz", + "integrity": "sha1-6ed2YfdsWWpv0O26YiAFZnFxuus=", + "requires": { + "@types/form-data": "*", + "@types/node": "*" + } + } + } + }, "spawn-error-forwarder": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/spawn-error-forwarder/-/spawn-error-forwarder-1.0.0.tgz", @@ -15507,6 +15746,18 @@ "through2": "^2.0.2" } }, + "sppull": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/sppull/-/sppull-2.4.1.tgz", + "integrity": "sha512-I3OuJfbbY4o1fTdTuLMpsWMQjL3EQ8+N11OfqV/s+cOL2XoUb5g+p6hvJrCTDTUMxe4X/5XpR6GRirJnpcImHw==", + "requires": { + "colors": "^1.3.3", + "mkdirp": "^0.5.1", + "node-sp-auth-config": "^2.6.7", + "request": "^2.88.0", + "sp-request": "^2.1.3" + } + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -16043,7 +16294,6 @@ "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, "requires": { "os-tmpdir": "~1.0.2" } @@ -17132,6 +17382,21 @@ "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, + "xmldoc": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/xmldoc/-/xmldoc-0.5.1.tgz", + "integrity": "sha1-kuQ36QDb/wRFDvrpDTyl8WVl9zg=", + "requires": { + "sax": "~1.1.1" + }, + "dependencies": { + "sax": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.1.6.tgz", + "integrity": "sha1-XWFr6KXmB9VOEUr65Vt+ry/MMkA=" + } + } + }, "xmldom": { "version": "0.1.27", "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.27.tgz", diff --git a/package.json b/package.json index 9b928cfb..c43aeaec 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "commit": "git-cz" }, "dependencies": { + "@azure/ms-rest-js": "1.8.13", "@microsoft/microsoft-graph-client": "1.6.0", "@semantic-release/exec": "3.3.2", "adal-node": "0.1.28", @@ -72,6 +73,7 @@ "cli-spinner": "0.2.10", "csv-parse": "4.4.1", "dotenv-extended": "2.4.0", + "empty-dir": "^2.0.0", "express": "4.16.4", "express-promise-router": "3.0.3", "fs-extra": "8.0.0", @@ -83,7 +85,6 @@ "mocha-typescript": "1.1.17", "ms": "2.1.1", "ms-rest-azure": "2.6.0", - "@azure/ms-rest-js": "1.8.13", "nexmo": "2.4.1", "ngrok": "3.1.1", "npm": "6.9.0", @@ -100,6 +101,7 @@ "sequelize-typescript": "0.6.10", "shx": "0.3.2", "simple-git": "1.113.0", + "sppull": "^2.4.1", "sqlite3": "4.0.8", "strict-password-generator": "1.1.2", "swagger-client": "^2.1.18", diff --git a/packages/admin.gbapp/dialogs/AdminDialog.ts b/packages/admin.gbapp/dialogs/AdminDialog.ts index 40d83d65..aaa672b0 100644 --- a/packages/admin.gbapp/dialogs/AdminDialog.ts +++ b/packages/admin.gbapp/dialogs/AdminDialog.ts @@ -36,7 +36,8 @@ 'use strict'; -var crypto = require('crypto') +const crypto = require('crypto'); +const emptyDir = require('empty-dir'); import { WaterfallDialog } from 'botbuilder-dialogs'; import { GBMinInstance, IGBDialog } from 'botlib'; import urlJoin = require('url-join'); @@ -45,6 +46,8 @@ import { GBConfigService } from '../../core.gbapp/services/GBConfigService'; import { GBDeployer } from '../../core.gbapp/services/GBDeployer'; import { GBImporter } from '../../core.gbapp/services/GBImporterService'; import { Messages } from '../strings'; +import { GBSharePointService } from '../../sharepoint.gblib/services/SharePointService'; +const Path = require('path'); /** * Dialogs for administration tasks. @@ -71,6 +74,18 @@ export class AdminDialog extends IGBDialog { } await deployer.deployPackage(min, urlJoin(additionalPath, packageName)); } + else { + let s = new GBSharePointService(); + let siteName = text.split(' ')[1]; + let folderName = text.split(' ')[2]; + + let localFolder = Path.join('tmp', Path.basename(folderName)); + await s.downloadFolder(localFolder, siteName, folderName, + GBConfigService.get('CLOUD_USERNAME'), GBConfigService.get('CLOUD_PASSWORD')) + await deployer.deployPackage(min, localFolder); + await emptyDir(localFolder); + + } } public static async rebuildIndexPackageCommand(min: GBMinInstance, deployer: GBDeployer) { @@ -215,7 +230,8 @@ export class AdminDialog extends IGBDialog { ); const locale = step.context.activity.locale; - const state = `${min.instance.instanceId}${crypto.getRandomValues(new Uint32Array(16))[0]}`; + const buf = Buffer.alloc(16); + const state = `${min.instance.instanceId}${crypto.randomFillSync(buf).toString('hex')}`; min.adminService.setValue(min.instance.instanceId, 'AntiCSRFAttackState', state); diff --git a/packages/core.gbapp/services/GBCoreService.ts b/packages/core.gbapp/services/GBCoreService.ts index 6da491e9..b2fc21a2 100644 --- a/packages/core.gbapp/services/GBCoreService.ts +++ b/packages/core.gbapp/services/GBCoreService.ts @@ -51,6 +51,9 @@ import { GBSecurityPackage } from '../../security.gblib'; import { GBWhatsappPackage } from '../../whatsapp.gblib/index'; import { GuaribasInstance } from '../models/GBModel'; import { GBConfigService } from './GBConfigService'; +import { GBAzureDeployerPackage } from '../../azuredeployer.gbapp'; +import { GBSharePointPackage } from '../../sharepoint.gblib'; + const opn = require('opn'); @@ -369,7 +372,9 @@ STORAGE_SYNC=true GBSecurityPackage, GBKBPackage, GBCustomerSatisfactionPackage, - GBWhatsappPackage + GBWhatsappPackage, + GBAzureDeployerPackage, + GBSharePointPackage, ].forEach(e => { GBLog.info(`Loading sys package: ${e.name}...`); diff --git a/packages/sharepoint.gblib/index.ts b/packages/sharepoint.gblib/index.ts new file mode 100644 index 00000000..36e7a04c --- /dev/null +++ b/packages/sharepoint.gblib/index.ts @@ -0,0 +1,65 @@ +/*****************************************************************************\ +| ( )_ _ | +| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ | +| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ | +| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) | +| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' | +| | | ( )_) | | +| (_) \___/' | +| | +| 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 { GBDialogStep, GBLog, GBMinInstance, IGBCoreService, IGBPackage } from 'botlib'; +import { Sequelize } from 'sequelize-typescript'; + +/** + * Package for Azure Deployer. + */ +export class GBSharePointPackage implements IGBPackage { + public sysPackages: IGBPackage[]; + public getDialogs(min: GBMinInstance) { + GBLog.verbose(`getDialogs called.`); + } + public loadPackage(core: IGBCoreService, sequelize: Sequelize): void { + GBLog.verbose(`loadPackage 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.`); + } +} diff --git a/packages/sharepoint.gblib/services/SharePointService.ts b/packages/sharepoint.gblib/services/SharePointService.ts new file mode 100644 index 00000000..1dfd97ef --- /dev/null +++ b/packages/sharepoint.gblib/services/SharePointService.ts @@ -0,0 +1,90 @@ +/*****************************************************************************\ +| ( )_ _ | +| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ | +| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ | +| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| (˅) |( (_) ) | +| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' | +| | | ( )_) | | +| (_) \___/' | +| | +| 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 { HttpHeaders, HttpMethods, ServiceClient, WebResource } from '@azure/ms-rest-js'; +import { CognitiveServicesManagementClient } from 'azure-arm-cognitiveservices'; +import { ResourceManagementClient, SubscriptionClient } from 'azure-arm-resource'; +import { SearchManagementClient } from 'azure-arm-search'; +import { SqlManagementClient } from 'azure-arm-sql'; +import { WebSiteManagementClient } from 'azure-arm-website'; +//tslint:disable-next-line:no-submodule-imports +import { AppServicePlan, Site, SiteConfigResource, SiteLogsConfig, SiteSourceControl } from 'azure-arm-website/lib/models'; +import { GBLog, IGBInstallationDeployer, IGBInstance } from 'botlib'; +import { GBAdminService } from '../../admin.gbapp/services/GBAdminService'; +import { GBCorePackage } from '../../core.gbapp'; +import { GBConfigService } from '../../core.gbapp/services/GBConfigService'; +import { GBDeployer } from '../../core.gbapp/services/GBDeployer'; +const MicrosoftGraph = require("@microsoft/microsoft-graph-client"); + +const Spinner = require('cli-spinner').Spinner; +// tslint:disable-next-line: no-submodule-imports +import * as simplegit from 'simple-git/promise'; +const git = simplegit(); + +// 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 publicIp = require('public-ip'); +const WebSiteResponseTimeout = 900; + +/** + * Service facade for SharePoint Online. + */ +export class GBSharePointService { + + public async downloadFolder(localPath: string, siteUrl: string, folderUrl: string, username: string, password: string) { + const { sppull } = require("sppull"); + + const context = { + siteUrl: siteUrl, + creds: { + username: username, + password: password + } + }; + + const options = { + spRootFolder: folderUrl, + dlRootFolder: localPath + }; + + return await sppull(context, options); + } + +} diff --git a/packages/sharepoint.gblib/strings.ts b/packages/sharepoint.gblib/strings.ts new file mode 100644 index 00000000..81ee4d60 --- /dev/null +++ b/packages/sharepoint.gblib/strings.ts @@ -0,0 +1,8 @@ +export const Messages = { + 'en-US': { + + }, + 'pt-BR': { + + } +};