From 83f4c4a48142bfcb49fd67103b99cc39792d1eb1 Mon Sep 17 00:00:00 2001 From: Vadim Feshchenko Date: Tue, 25 Jul 2023 18:18:52 +0300 Subject: [PATCH 1/7] [AGX-1965] - Investigation '/schedule_integration' file upload issue, SPIKE - temp branch --- package-lock.json | 150 +++++++++-------------- packages/client/src/Home/Form.jsx | 2 +- packages/client/src/Home/MethodInput.jsx | 1 + packages/server/package.json | 3 +- packages/server/src/routes/proxy.js | 33 +++++ 5 files changed, 93 insertions(+), 96 deletions(-) diff --git a/package-lock.json b/package-lock.json index f9f67ec..870c4ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3489,15 +3489,15 @@ } }, "node_modules/@procore/js-sdk": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@procore/js-sdk/-/js-sdk-3.0.2.tgz", - "integrity": "sha512-iAZUtJPfXQAZ+Px+wVmHUNsgFGD7CJ5gmIPKRCHYIU/eI6LPd4GAV392NAebbDMWhMSbXSP91jD7ZpvUdOmsWQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@procore/js-sdk/-/js-sdk-4.0.2.tgz", + "integrity": "sha512-xJ/u/YcE6ZX9eUatQywekjnccKT83us97cKES9GnlXgqv0SFBktW0CFyTj108YVR5kWAvNrsYuyxTI5+jEytUA==", "dependencies": { "isomorphic-fetch": "^3.0.0", - "qs": "^6.10" + "qs": "^6.11.1" }, "engines": { - "node": ">= 10.12.0" + "node": ">= 14.15.0" } }, "node_modules/@procore/js-sdk-sample-app-client": { @@ -4101,8 +4101,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/at-least-node": { "version": "1.0.0", @@ -4875,7 +4874,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -5378,7 +5376,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -6011,7 +6008,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dev": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -8365,9 +8361,9 @@ "dev": true }, "node_modules/nodemon": { - "version": "2.0.20", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", - "integrity": "sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", + "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", "dev": true, "dependencies": { "chokidar": "^3.5.2", @@ -8375,8 +8371,8 @@ "ignore-by-default": "^1.0.1", "minimatch": "^3.1.2", "pstree.remy": "^1.1.8", - "semver": "^5.7.1", - "simple-update-notifier": "^1.0.7", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", "supports-color": "^5.5.0", "touch": "^3.1.0", "undefsafe": "^2.0.5" @@ -8385,7 +8381,7 @@ "nodemon": "bin/nodemon.js" }, "engines": { - "node": ">=8.10.0" + "node": ">=10" }, "funding": { "type": "opencollective", @@ -8410,15 +8406,6 @@ "node": ">=4" } }, - "node_modules/nodemon/node_modules/semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true, - "bin": { - "semver": "bin/semver" - } - }, "node_modules/nodemon/node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -8935,9 +8922,9 @@ } }, "node_modules/object-inspect": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", - "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -9661,9 +9648,9 @@ } }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", "dependencies": { "side-channel": "^1.0.4" }, @@ -10522,9 +10509,9 @@ } }, "node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "dependencies": { "lru-cache": "^6.0.0" @@ -10699,24 +10686,15 @@ "dev": true }, "node_modules/simple-update-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", - "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", "dev": true, "dependencies": { - "semver": "~7.0.0" + "semver": "^7.5.3" }, "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/simple-update-notifier/node_modules/semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" + "node": ">=10" } }, "node_modules/slash": { @@ -12124,19 +12102,20 @@ "version": "1.2.0", "license": "MIT", "dependencies": { - "@procore/js-sdk": "3.0.2", + "@procore/js-sdk": "4.0.2", "cookie-parser": "1.4.5", "cookie-session": "1.4.0", "dotenv": "8.2.0", "esm": "3.2.25", "express": "4.17.3", + "form-data": "^4.0.0", "http-errors": "1.8.0", "http-proxy": "1.18.1", "morgan": "1.10.0", "pug": "3.0.2" }, "devDependencies": { - "nodemon": "2.0.20", + "nodemon": "^3.0.1", "prettier": "2.3.2" } }, @@ -14732,12 +14711,12 @@ } }, "@procore/js-sdk": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@procore/js-sdk/-/js-sdk-3.0.2.tgz", - "integrity": "sha512-iAZUtJPfXQAZ+Px+wVmHUNsgFGD7CJ5gmIPKRCHYIU/eI6LPd4GAV392NAebbDMWhMSbXSP91jD7ZpvUdOmsWQ==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@procore/js-sdk/-/js-sdk-4.0.2.tgz", + "integrity": "sha512-xJ/u/YcE6ZX9eUatQywekjnccKT83us97cKES9GnlXgqv0SFBktW0CFyTj108YVR5kWAvNrsYuyxTI5+jEytUA==", "requires": { "isomorphic-fetch": "^3.0.0", - "qs": "^6.10" + "qs": "^6.11.1" } }, "@procore/js-sdk-sample-app-client": { @@ -14773,16 +14752,17 @@ "@procore/js-sdk-sample-app-server": { "version": "file:packages/server", "requires": { - "@procore/js-sdk": "3.0.2", + "@procore/js-sdk": "4.0.2", "cookie-parser": "1.4.5", "cookie-session": "1.4.0", "dotenv": "8.2.0", "esm": "3.2.25", "express": "4.17.3", + "form-data": "^4.0.0", "http-errors": "1.8.0", "http-proxy": "1.18.1", "morgan": "1.10.0", - "nodemon": "2.0.20", + "nodemon": "3.0.1", "prettier": "2.3.2", "pug": "3.0.2" }, @@ -15309,8 +15289,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "at-least-node": { "version": "1.0.0", @@ -15893,7 +15872,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -16295,8 +16273,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" }, "delegates": { "version": "1.0.0", @@ -16792,7 +16769,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dev": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -18622,9 +18598,9 @@ "dev": true }, "nodemon": { - "version": "2.0.20", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", - "integrity": "sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz", + "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==", "dev": true, "requires": { "chokidar": "^3.5.2", @@ -18632,8 +18608,8 @@ "ignore-by-default": "^1.0.1", "minimatch": "^3.1.2", "pstree.remy": "^1.1.8", - "semver": "^5.7.1", - "simple-update-notifier": "^1.0.7", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", "supports-color": "^5.5.0", "touch": "^3.1.0", "undefsafe": "^2.0.5" @@ -18654,12 +18630,6 @@ "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -19066,9 +19036,9 @@ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" }, "object-inspect": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", - "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==" + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==" }, "on-finished": { "version": "2.3.0", @@ -19636,9 +19606,9 @@ "dev": true }, "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", "requires": { "side-channel": "^1.0.4" } @@ -20293,9 +20263,9 @@ } }, "semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -20443,20 +20413,12 @@ "dev": true }, "simple-update-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", - "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", "dev": true, "requires": { - "semver": "~7.0.0" - }, - "dependencies": { - "semver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", - "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", - "dev": true - } + "semver": "^7.5.3" } }, "slash": { diff --git a/packages/client/src/Home/Form.jsx b/packages/client/src/Home/Form.jsx index 85462b8..cc43922 100644 --- a/packages/client/src/Home/Form.jsx +++ b/packages/client/src/Home/Form.jsx @@ -20,7 +20,7 @@ const FormContainer = styled('form')(({ theme }) => ({ export function Form(props) { const [version, setVersion] = React.useState('v1.0'); - const [endpoint, setEndpoint] = React.useState('/me'); + const [endpoint, setEndpoint] = React.useState('/schedule_integration'); const [method, setMethod] = React.useState('get'); const [qs, setQs] = React.useState([]); diff --git a/packages/client/src/Home/MethodInput.jsx b/packages/client/src/Home/MethodInput.jsx index e88530c..179081e 100644 --- a/packages/client/src/Home/MethodInput.jsx +++ b/packages/client/src/Home/MethodInput.jsx @@ -15,6 +15,7 @@ export function MethodInput(props) { Method } label="GET" /> + } label="PUT" /> ); diff --git a/packages/server/package.json b/packages/server/package.json index 4f2ef3b..2b34a1b 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -21,13 +21,14 @@ "dotenv": "8.2.0", "esm": "3.2.25", "express": "4.17.3", + "form-data": "^4.0.0", "http-errors": "1.8.0", "http-proxy": "1.18.1", "morgan": "1.10.0", "pug": "3.0.2" }, "devDependencies": { - "nodemon": "2.0.20", + "nodemon": "^3.0.1", "prettier": "2.3.2" } } diff --git a/packages/server/src/routes/proxy.js b/packages/server/src/routes/proxy.js index 28b7ca3..a9b3e2b 100644 --- a/packages/server/src/routes/proxy.js +++ b/packages/server/src/routes/proxy.js @@ -1,6 +1,8 @@ import { Router } from 'express'; import { client, oauth } from '@procore/js-sdk'; import { clientOptions } from '../clientOptions'; +const fs = require('fs'); +var FormData = require('form-data'); let pcorClient = undefined; function getClient(accessToken, defaults) { @@ -25,11 +27,42 @@ proxyRouter.all('*', async (req, res) => { endpoint = [...path].slice(2); } [endpoint] = endpoint.join('/').split('?'); + endpoint = 'schedule_integration'; + + var inner = { + file: fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml'), + options: { + filename: 'abcd.xml', + contentType: 'multipart/form-data', + 'Content-Type': 'multipart/form-data' + } + }; + const formData = new FormData(); + formData.append('schedule_integration', JSON.stringify(inner)); + + req.query = { + 'project_id': 1884702, + 'schedule_integration': inner + }; + + req.headers['accept'] = 'application/json'; + req.headers['content-type'] = 'multipart/form-data'; + // req.headers['content-type'] = 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'; try { const result = await procore[method.toLowerCase()]({ base: `/${endpoint}`, version: version, + accept: 'application/json', + contentType: 'multipart/form-data', // Seems like 'contentType" or 'headers' does not really pass + 'headers': { + 'accept': 'application/json', + 'content-type': 'multipart/form-data', + 'Content-Type': 'multipart/form-data' + }, + data: formData, // That is not necessary + body: formData, // That is not necessary + form: formData, // That is not necessary qs: JSON.parse(JSON.stringify(req.query)) }); return res.json(result.body); From 357a9881deaeeb6041d56c29056a6cf6ae8be80d Mon Sep 17 00:00:00 2001 From: Vadim Feshchenko Date: Mon, 31 Jul 2023 18:16:17 +0300 Subject: [PATCH 2/7] [AGX-1992] - modify 'packages/server/package.json' to use '@procore/js-sdk' from local --- packages/server/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/package.json b/packages/server/package.json index 2b34a1b..0bd63c0 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -15,7 +15,7 @@ "format": "prettier --config ../../prettier.config.js --write ." }, "dependencies": { - "@procore/js-sdk": "4.0.2", + "@procore/js-sdk": "/Users/vfeshchenko/Projects/procore/js-sdk", "cookie-parser": "1.4.5", "cookie-session": "1.4.0", "dotenv": "8.2.0", From 548afc0b1574472f483676d309b9e9ebf0cf4abb Mon Sep 17 00:00:00 2001 From: Vadim Feshchenko Date: Mon, 31 Jul 2023 18:17:02 +0300 Subject: [PATCH 3/7] [AGX-1992] - modify 'src/routes/proxy' --- packages/server/src/routes/proxy.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/server/src/routes/proxy.js b/packages/server/src/routes/proxy.js index a9b3e2b..af6e8a2 100644 --- a/packages/server/src/routes/proxy.js +++ b/packages/server/src/routes/proxy.js @@ -53,16 +53,14 @@ proxyRouter.all('*', async (req, res) => { const result = await procore[method.toLowerCase()]({ base: `/${endpoint}`, version: version, - accept: 'application/json', + contentType: 'multipart/form-data', // Seems like 'contentType" or 'headers' does not really pass 'headers': { 'accept': 'application/json', 'content-type': 'multipart/form-data', 'Content-Type': 'multipart/form-data' }, - data: formData, // That is not necessary - body: formData, // That is not necessary - form: formData, // That is not necessary + qs: JSON.parse(JSON.stringify(req.query)) }); return res.json(result.body); From 17b404e70e30fe6a4d67c7e461a2c626e1507dcd Mon Sep 17 00:00:00 2001 From: Vadim Feshchenko Date: Thu, 3 Aug 2023 18:22:20 +0300 Subject: [PATCH 4/7] [AGX-1965] - Set back js-sdk@4.0.2 --- packages/server/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/package.json b/packages/server/package.json index 0bd63c0..2b34a1b 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -15,7 +15,7 @@ "format": "prettier --config ../../prettier.config.js --write ." }, "dependencies": { - "@procore/js-sdk": "/Users/vfeshchenko/Projects/procore/js-sdk", + "@procore/js-sdk": "4.0.2", "cookie-parser": "1.4.5", "cookie-session": "1.4.0", "dotenv": "8.2.0", From 1bd98adefa65f3379accd6df45c11f9ad8fff9d6 Mon Sep 17 00:00:00 2001 From: Vadim Feshchenko Date: Thu, 3 Aug 2023 18:23:47 +0300 Subject: [PATCH 5/7] [AGX-1965] - Add passing 'body' and 'RequestConfig:Headers' directly --- packages/server/src/routes/proxy.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/server/src/routes/proxy.js b/packages/server/src/routes/proxy.js index af6e8a2..2697d1c 100644 --- a/packages/server/src/routes/proxy.js +++ b/packages/server/src/routes/proxy.js @@ -42,27 +42,28 @@ proxyRouter.all('*', async (req, res) => { req.query = { 'project_id': 1884702, + // 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') 'schedule_integration': inner }; - req.headers['accept'] = 'application/json'; - req.headers['content-type'] = 'multipart/form-data'; - // req.headers['content-type'] = 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'; - try { const result = await procore[method.toLowerCase()]({ base: `/${endpoint}`, version: version, - - contentType: 'multipart/form-data', // Seems like 'contentType" or 'headers' does not really pass - 'headers': { - 'accept': 'application/json', - 'content-type': 'multipart/form-data', - 'Content-Type': 'multipart/form-data' - }, - qs: JSON.parse(JSON.stringify(req.query)) - }); + }, + { 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') + // { schedule_integration: { + // file: fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') + // } + }, + { + headers: { + 'content-type': 'multipart/form-data', + 'test-header': 'is_passed?' + } + } + ); return res.json(result.body); } catch (error) { return res.json(error.body); From f69ea2958ae55a92da9871e20ff010226410991d Mon Sep 17 00:00:00 2001 From: Vadim Feshchenko Date: Thu, 3 Aug 2023 18:35:39 +0300 Subject: [PATCH 6/7] [AGX-1965] - Pass 'schedule_integration.file' as a querry parameter --- packages/server/src/routes/proxy.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/server/src/routes/proxy.js b/packages/server/src/routes/proxy.js index 2697d1c..ac7b895 100644 --- a/packages/server/src/routes/proxy.js +++ b/packages/server/src/routes/proxy.js @@ -42,8 +42,8 @@ proxyRouter.all('*', async (req, res) => { req.query = { 'project_id': 1884702, - // 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') - 'schedule_integration': inner + 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') + // 'schedule_integration': inner }; try { @@ -52,11 +52,12 @@ proxyRouter.all('*', async (req, res) => { version: version, qs: JSON.parse(JSON.stringify(req.query)) }, - { 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') + {}, + // { 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') // { schedule_integration: { // file: fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') // } - }, + // }, { headers: { 'content-type': 'multipart/form-data', From 41c7bfee6002de132b9f0e3401b164e5f8688f73 Mon Sep 17 00:00:00 2001 From: Vadim Feshchenko Date: Wed, 16 Aug 2023 17:45:54 +0300 Subject: [PATCH 7/7] [AGX-1965] - Add 'formData.append' test --- packages/server/src/routes/proxy.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/server/src/routes/proxy.js b/packages/server/src/routes/proxy.js index ac7b895..9c836ca 100644 --- a/packages/server/src/routes/proxy.js +++ b/packages/server/src/routes/proxy.js @@ -38,12 +38,16 @@ proxyRouter.all('*', async (req, res) => { } }; const formData = new FormData(); - formData.append('schedule_integration', JSON.stringify(inner)); + // formData.append('schedule_integration', JSON.stringify(inner)); + + const fileStream = fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml'); + // formData.append('file', fileStream, 'test.xml'); + formData.append('schedule_integration[file]', fileStream, 'test.xml'); req.query = { 'project_id': 1884702, - 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') - // 'schedule_integration': inner + 'schedule_integration[file]': 'fake' + // formData }; try { @@ -52,7 +56,13 @@ proxyRouter.all('*', async (req, res) => { version: version, qs: JSON.parse(JSON.stringify(req.query)) }, - {}, + // { 'schedule_integration[file]': 'fake' + // { 'schedule_integration': inner + // { 'schedule_integration': formData + // { formData + { 'schedule_integration': { 'file': 'fake', 'original_filename': 'test' } + }, // status code 400, 'param is missing or the value is empty: schedule_integration' + // {}, // { 'schedule_integration[file]': fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml') // { schedule_integration: { // file: fs.createReadStream('/Users/vfeshchenko/temp/abcd.xml')