From 0c302137ce77722668df9a8a64479869a6693453 Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 22 Nov 2021 15:35:45 -0500 Subject: [PATCH 01/13] template for donwloading, still buggy --- downloader.js | 32 ++++++++++++++++++++++++++++++++ taskRunner.js | 20 +++++++++++++++++--- watcher.js | 27 +++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 downloader.js diff --git a/downloader.js b/downloader.js new file mode 100644 index 0000000..2727216 --- /dev/null +++ b/downloader.js @@ -0,0 +1,32 @@ +const axios = require('axios'); +const fs = require('fs').promises; + +/** + * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 + * + * Downloads a file by making a GET request on the storageUrl and then + * saves the file as `filename` under the `destination` directory + * @param {String} storageUrl + * @param {String} fileName + * @param {String} destination + * @param {Object} credentials + */ +exports.download = async (storageUrl, fileName, destination, credentials) => { + await axios({ + method: 'GET', + url: storageUrl, + headers: { + Authorization: `Bearer ${credentials.access_token}` + } + }) + .then(async res => { + fs.writeFile(`./${destination}/${fileName}`, res.data).then(() => { + console.log("finished downloading", fileName); + }); + }) + .catch(err => { + console.log("error while processing " + fileName); + // console.log(err); + }); +} + diff --git a/taskRunner.js b/taskRunner.js index 47e7144..ac29f2b 100644 --- a/taskRunner.js +++ b/taskRunner.js @@ -1,5 +1,6 @@ const axios = require('axios'); const watcher = require('./watcher'); +const downloader = require('./downloader'); require('dotenv').config(); /** @@ -14,6 +15,8 @@ require('dotenv').config(); // TODO const projectID = "" +// TODO: create map from cloud directories to local + // parse command line arguments from docker-compose to get folder ID const folderIdMap = { gantry: "GANTRY_FOLDER_ID", @@ -88,7 +91,7 @@ const getCredentials = () => { /** * Function to dispatch the watcher */ -const dispatchWatcher = (interval) => { +const dispatchWatcher = async (interval) => { if (credentials === null) { console.log( '\x1b[93mtaskRunner.js::dispatchWatcher:', @@ -96,12 +99,23 @@ const dispatchWatcher = (interval) => { ); return; } + + const items = await watcher.watch(adminProjectID, adminProjectTopFolder, credentials, interval); + + if (Object.keys(items).length == 0) { + return; // no items to download + } - watcher.watch(adminProjectID, adminProjectTopFolder, credentials, interval); + for (index in items) { + // dispatch the downloader here + console.log(items[index].name); + downloader.download(items[index].url, items[index].name, 'download_tests', credentials); + } }; getCredentials(); // There should be a buffer between how far back the watcher checks // and how often it runs. We may need to test this out. -setInterval(dispatchWatcher, 5000, 7000); \ No newline at end of file +setInterval(dispatchWatcher, 5000); + diff --git a/watcher.js b/watcher.js index 1b78f7a..1cdae5b 100644 --- a/watcher.js +++ b/watcher.js @@ -10,6 +10,8 @@ const axios = require('axios'); * @param {Object} credentials credentials for the call * @param {Integer} interval number of ms used to filter the date * if an interval is not passed, watcher will return all files in the given folder + * + * @return {Object} changedItems array of items changed that need to be downloaded */ exports.watch = (projectID, folderID, credentials, interval) => { let timeFilter = {}; @@ -19,10 +21,12 @@ exports.watch = (projectID, folderID, credentials, interval) => { var dateXSecondsAgo = new Date(dateNow.getTime() - interval); timeFilter = { 'filter[lastModifiedTime]-ge': dateXSecondsAgo.toISOString() }; } + console.log( '\x1b[96mwatcher.js::watch:', '\x1b[0mChecking for files modified since ' + interval/1000 + ' sec ago'); - axios({ + + const items = axios({ method: 'GET', url: `https://developer.api.autodesk.com/data/v1/projects/${projectID}/folders/${folderID}/contents`, headers: { @@ -41,16 +45,33 @@ exports.watch = (projectID, folderID, credentials, interval) => { return; } + let changedItems = {}; + for (var index in data) { // console.log(data[index]); const displayName = data[index].attributes.displayName; + const name = data[index].attributes.name; + var saveName = displayName; + + if (displayName.lastIndexOf('.') != name.lastIndexOf('.')) { + saveName += name.substring(name.lastIndexOf('.')); + } + const lastModifiedTime = data[index].attributes.lastModifiedTime; + const storageUrl = data[index].relationships.storage.meta.link.href; console.log('\x1b[92mwatcher.js::watch: \x1b[0m' + displayName + ' was modified at ' + lastModifiedTime); // TODO: if item is not in db, add to db and then download - // TODO: if item is in db, check and compare lastModifiedTime + // TODO: if item is in db, check and compare lastModifiedTime then download those + // where time does not match with db time + + // index will have to change because not all items may need to be added to this list + changedItems[index] = {name: saveName, url: storageUrl}; + // console.log(changedItems); } + + return changedItems; }) .catch(err => { console.log( @@ -58,4 +79,6 @@ exports.watch = (projectID, folderID, credentials, interval) => { '\x1b[0mError accessing Forge folder contents API' ); }); + + return items; }; From 79da169cca21731d4d3e76faf6a1b0cf525738e7 Mon Sep 17 00:00:00 2001 From: pan261 Date: Mon, 29 Nov 2021 17:45:49 -0500 Subject: [PATCH 02/13] downloading fix --- downloader.js | 61 ++++++++++++++++++++++++++++++++++++++------------- watcher.js | 6 +++-- 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/downloader.js b/downloader.js index 2727216..779601e 100644 --- a/downloader.js +++ b/downloader.js @@ -1,5 +1,21 @@ const axios = require('axios'); const fs = require('fs').promises; +const ForgeSDK = require('forge-apis'); +require('dotenv').config(); + + +const ObjectsApi = new ForgeSDK.ObjectsApi(); + +const scopes = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write']; + +const authClient = new ForgeSDK.AuthClientThreeLegged( + process.env.FORGE_CLIENT_ID, + process.env.FORGE_CLIENT_SECRET, + process.env.FORGE_CALLBACK_URL, + scopes, + true +); + /** * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 @@ -11,22 +27,37 @@ const fs = require('fs').promises; * @param {String} destination * @param {Object} credentials */ -exports.download = async (storageUrl, fileName, destination, credentials) => { - await axios({ - method: 'GET', - url: storageUrl, - headers: { - Authorization: `Bearer ${credentials.access_token}` - } - }) - .then(async res => { - fs.writeFile(`./${destination}/${fileName}`, res.data).then(() => { - console.log("finished downloading", fileName); - }); +exports.download = (storageUrl, fileName, destination, credentials) => { + // var file = fs.createWriteStream(`./${destination}/${fileName}`); + + // await axios({ + // method: 'GET', + // url: storageUrl, + // headers: { + // Authorization: `Bearer ${credentials.access_token}` + // } + // }) + // .then(res => {return res.data}) + // .then(async res => { + // // console.log(res.data); + // // fs.writeFile(`./${destination}/${fileName}`, res.data, 'binary').then(() => { + // // console.log("finished downloading", fileName); + // // }); + // fs.WriteStream(`./${destination}/${fileName}`).write(res); + // }) + // .catch(err => { + // console.log("error while processing " + fileName); + // console.log(err); + // }); + + ObjectsApi.getObject('wip.dm.prod', storageUrl, {}, authClient, credentials) + .then((res) => { + console.log(res) + fs.writeFile(`./${destination}/${fileName}`, res.body) }) - .catch(err => { - console.log("error while processing " + fileName); - // console.log(err); + .catch((err) => { + console.log("error while processing " + storageUrl); + console.log(err); }); } diff --git a/watcher.js b/watcher.js index 1cdae5b..9848227 100644 --- a/watcher.js +++ b/watcher.js @@ -42,7 +42,7 @@ exports.watch = (projectID, folderID, credentials, interval) => { console.log( '\x1b[96mwatcher.js::watch:', '\x1b[0mNo new files modified since ' + dateXSecondsAgo.toISOString()); - return; + return {}; } let changedItems = {}; @@ -59,6 +59,8 @@ exports.watch = (projectID, folderID, credentials, interval) => { const lastModifiedTime = data[index].attributes.lastModifiedTime; const storageUrl = data[index].relationships.storage.meta.link.href; + var storageID = data[index].relationships.storage.data.id; + storageID = storageID.substring(storageID.indexOf('/') + 1); console.log('\x1b[92mwatcher.js::watch: \x1b[0m' + displayName + ' was modified at ' + lastModifiedTime); // TODO: if item is not in db, add to db and then download @@ -67,7 +69,7 @@ exports.watch = (projectID, folderID, credentials, interval) => { // where time does not match with db time // index will have to change because not all items may need to be added to this list - changedItems[index] = {name: saveName, url: storageUrl}; + changedItems[index] = {name: saveName, url: storageID}; // console.log(changedItems); } From f5e309d968a5e49908449f168f5ffc54c4d33a6a Mon Sep 17 00:00:00 2001 From: pan261 Date: Tue, 30 Nov 2021 13:13:13 -0500 Subject: [PATCH 03/13] added config file --- config.js | 33 +++++++++++++++++++++++++++++++++ downloader.js | 50 ++++++++------------------------------------------ server.js | 28 +++++++++------------------- taskRunner.js | 17 +++++------------ watcher.js | 5 +++-- 5 files changed, 58 insertions(+), 75 deletions(-) create mode 100644 config.js diff --git a/config.js b/config.js new file mode 100644 index 0000000..aad2b35 --- /dev/null +++ b/config.js @@ -0,0 +1,33 @@ +/** + * Configures constants used in the other parts of this app + */ + +require('dotenv').config(); +const ForgeAuthClient = require('forge-apis').AuthClientThreeLegged; + +const scopes = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write']; + +const authClient = new ForgeAuthClient( + process.env.FORGE_CLIENT_ID, + process.env.FORGE_CLIENT_SECRET, + process.env.FORGE_CALLBACK_URL, + scopes, + true +); + +const folderIdMap = { + gantry: "GANTRY_FOLDER_ID", + lathe: "LATHE_FOLDER_ID", + mill: "MILL_FOLDER_ID", + waterjet: "WATERJET_FOLDER_ID" +}; + +module.exports = { + authClient: authClient, + scopes: scopes, + folderIdMap: folderIdMap, + port: process.env.PORT, + forgeClientId: process.env.FORGE_CLIENT_ID, + forgeClientSecret: process.env.FORGE_CLIENT_SECRET, + forgeCallbackURL: process.env.FORGE_CALLBACK_URL +} \ No newline at end of file diff --git a/downloader.js b/downloader.js index 779601e..35b3e2b 100644 --- a/downloader.js +++ b/downloader.js @@ -1,62 +1,28 @@ -const axios = require('axios'); const fs = require('fs').promises; const ForgeSDK = require('forge-apis'); -require('dotenv').config(); - +const config = require('./config'); const ObjectsApi = new ForgeSDK.ObjectsApi(); -const scopes = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write']; - -const authClient = new ForgeSDK.AuthClientThreeLegged( - process.env.FORGE_CLIENT_ID, - process.env.FORGE_CLIENT_SECRET, - process.env.FORGE_CALLBACK_URL, - scopes, - true -); - - /** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 + * Kevin Pan | pan261@purdue.edu | Last Modified: 11/30/2021 * - * Downloads a file by making a GET request on the storageUrl and then - * saves the file as `filename` under the `destination` directory - * @param {String} storageUrl + * Downloads a file by using the Forge SDK to make a GET request + * on the storageLocation and then saves the file as `filename` under the `destination` directory + * @param {String} storageLocation * @param {String} fileName * @param {String} destination * @param {Object} credentials */ -exports.download = (storageUrl, fileName, destination, credentials) => { - // var file = fs.createWriteStream(`./${destination}/${fileName}`); - - // await axios({ - // method: 'GET', - // url: storageUrl, - // headers: { - // Authorization: `Bearer ${credentials.access_token}` - // } - // }) - // .then(res => {return res.data}) - // .then(async res => { - // // console.log(res.data); - // // fs.writeFile(`./${destination}/${fileName}`, res.data, 'binary').then(() => { - // // console.log("finished downloading", fileName); - // // }); - // fs.WriteStream(`./${destination}/${fileName}`).write(res); - // }) - // .catch(err => { - // console.log("error while processing " + fileName); - // console.log(err); - // }); +exports.download = (storageLocation, fileName, destination, credentials) => { - ObjectsApi.getObject('wip.dm.prod', storageUrl, {}, authClient, credentials) + ObjectsApi.getObject('wip.dm.prod', storageLocation, {}, config.authClient, credentials) .then((res) => { console.log(res) fs.writeFile(`./${destination}/${fileName}`, res.body) }) .catch((err) => { - console.log("error while processing " + storageUrl); + console.log("error while processing " + storageLocation); console.log(err); }); } diff --git a/server.js b/server.js index bf079d6..48d5d4c 100644 --- a/server.js +++ b/server.js @@ -1,7 +1,5 @@ const express = require('express'); -require('dotenv').config(); - -const ForgeSDK = require('forge-apis'); +const config = require('./config'); /** * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 @@ -14,18 +12,10 @@ const ForgeSDK = require('forge-apis'); * - FORGE_CALLBACK_URL * - PORT (defaults to 3000) * + * These are all configured in config.js + * */ -const scopes = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write']; - -const oAuth2ThreeLegged = new ForgeSDK.AuthClientThreeLegged( - process.env.FORGE_CLIENT_ID, - process.env.FORGE_CLIENT_SECRET, - process.env.FORGE_CALLBACK_URL, - scopes, - true -); - let credentials = null; let refreshTime = null; let intervalID = null; @@ -42,9 +32,9 @@ let intervalID = null; */ const createServer = () => { const app = express(); - const PORT = process.env.PORT || 3000; + const PORT = config.port || 3000; - if (process.env.FORGE_CLIENT_ID == null || process.env.FORGE_CLIENT_SECRET == null) { + if (config.forgeClientId == null || config.forgeClientSecret == null) { console.error('Missing FORGE_CLIENT_ID or FORGE_CLIENT_SECRET env. variables.'); return; } @@ -55,12 +45,12 @@ const createServer = () => { '\x1b[96mserver.js::createServer:', '\x1b[0m/auth endpoint called' ); - res.redirect(oAuth2ThreeLegged.generateAuthUrl()); + res.redirect(config.authClient.generateAuthUrl()); }); // Endpoint Forge redirects to after consent screen app.get('/callback', function (req, res) { - oAuth2ThreeLegged.getToken(req.query.code) + config.authClient.getToken(req.query.code) .then((creds) => { credentials = creds; refreshTime = creds.expires_in - 300; @@ -113,7 +103,7 @@ const createServer = () => { res.status(err.statusCode).json(err); }); - const server = app.listen(PORT, () => { console.log(`Server listening on port ${PORT}`); }); + const server = app.listen(config.port, () => { console.log(`Server listening on port ${PORT}`); }); return server; } @@ -122,7 +112,7 @@ const createServer = () => { * Used internally to refresh tokens automatically */ const refresh = () => { - oAuth2ThreeLegged.refreshToken(credentials, scopes) + config.authClient.refreshToken(credentials, scopes) .then(creds => { credentials = creds; console.log( diff --git a/taskRunner.js b/taskRunner.js index ac29f2b..acb9ecb 100644 --- a/taskRunner.js +++ b/taskRunner.js @@ -1,10 +1,10 @@ const axios = require('axios'); const watcher = require('./watcher'); const downloader = require('./downloader'); -require('dotenv').config(); +const config = require('./config'); /** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 + * Kevin Pan | pan261@purdue.edu | Last Modified: 11/30/2021 * * This file will be responsible for managing the watcher * as well as fetching the credentials from the server @@ -18,14 +18,8 @@ const projectID = "" // TODO: create map from cloud directories to local // parse command line arguments from docker-compose to get folder ID -const folderIdMap = { - gantry: "GANTRY_FOLDER_ID", - lathe: "LATHE_FOLDER_ID", - mill: "MILL_FOLDER_ID", - waterjet: "WATERJET_FOLDER_ID" -}; -const folderID = folderIdMap[process.argv[2]]; +const folderID = config.folderIdMap[process.argv[2]]; console.log(folderID); const adminProjectID = 'a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTEwODQ2NDQzMzk3Ng'; @@ -108,8 +102,7 @@ const dispatchWatcher = async (interval) => { for (index in items) { // dispatch the downloader here - console.log(items[index].name); - downloader.download(items[index].url, items[index].name, 'download_tests', credentials); + downloader.download(items[index].location, items[index].name, 'download_tests', credentials); } }; @@ -117,5 +110,5 @@ getCredentials(); // There should be a buffer between how far back the watcher checks // and how often it runs. We may need to test this out. -setInterval(dispatchWatcher, 5000); +setInterval(dispatchWatcher, 5000, 7000); diff --git a/watcher.js b/watcher.js index 9848227..a321e97 100644 --- a/watcher.js +++ b/watcher.js @@ -1,7 +1,7 @@ const axios = require('axios'); /** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 + * Kevin Pan | pan261@purdue.edu | Last Modified: 11/30/2021 * * Watches given folder id in the project, logs any files changed since * `interval` ms ago @@ -69,7 +69,7 @@ exports.watch = (projectID, folderID, credentials, interval) => { // where time does not match with db time // index will have to change because not all items may need to be added to this list - changedItems[index] = {name: saveName, url: storageID}; + changedItems[index] = {name: saveName, location: storageID}; // console.log(changedItems); } @@ -80,6 +80,7 @@ exports.watch = (projectID, folderID, credentials, interval) => { '\x1b[91mwatcher.js::watch:', '\x1b[0mError accessing Forge folder contents API' ); + return {}; }); return items; From 5d6089b2b21c966f88c69abae2be9b01beafb9c6 Mon Sep 17 00:00:00 2001 From: pan261 Date: Tue, 30 Nov 2021 13:44:38 -0500 Subject: [PATCH 04/13] moved js code into 'src' directory --- docker-compose.yml | 10 ++++++---- Dockerfile => src/Dockerfile | 4 ++-- config.js => src/config.js | 5 ++++- downloader.js => src/downloader.js | 0 package-lock.json => src/package-lock.json | 0 package.json => src/package.json | 0 server.js => src/server.js | 2 +- taskRunner.js => src/taskRunner.js | 0 watcher.js => src/watcher.js | 0 9 files changed, 13 insertions(+), 8 deletions(-) rename Dockerfile => src/Dockerfile (58%) rename config.js => src/config.js (91%) rename downloader.js => src/downloader.js (100%) rename package-lock.json => src/package-lock.json (100%) rename package.json => src/package.json (100%) rename server.js => src/server.js (98%) rename taskRunner.js => src/taskRunner.js (100%) rename watcher.js => src/watcher.js (100%) diff --git a/docker-compose.yml b/docker-compose.yml index 849e3f9..9b43816 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,11 @@ version: "3.8" services: auth_server: build: - context: . + context: ./src + dockerfile: Dockerfile env_file: ./.env volumes: - - .:/ffs/ + - ./src:/ffs/ - /ffs/node_modules ports: - "3000:3000" @@ -13,10 +14,11 @@ services: task_runner_1: build: - context: . + context: ./src + dockerfile: Dockerfile env_file: ./.env volumes: - - .:/ffs/ + - ./src:/ffs/ - /ffs/node_modules network_mode: host command: "node taskRunner.js lathe" \ No newline at end of file diff --git a/Dockerfile b/src/Dockerfile similarity index 58% rename from Dockerfile rename to src/Dockerfile index b76e794..3eb3686 100644 --- a/Dockerfile +++ b/src/Dockerfile @@ -1,5 +1,5 @@ FROM node:16 WORKDIR /ffs/ -COPY package.json . +COPY package.json ./ RUN npm install -COPY . . \ No newline at end of file +COPY . ./ \ No newline at end of file diff --git a/config.js b/src/config.js similarity index 91% rename from config.js rename to src/config.js index aad2b35..d1b9c01 100644 --- a/config.js +++ b/src/config.js @@ -2,7 +2,10 @@ * Configures constants used in the other parts of this app */ -require('dotenv').config(); +const dotenv = require('dotenv'); + +dotenv.config({path: '../.env'}); + const ForgeAuthClient = require('forge-apis').AuthClientThreeLegged; const scopes = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write']; diff --git a/downloader.js b/src/downloader.js similarity index 100% rename from downloader.js rename to src/downloader.js diff --git a/package-lock.json b/src/package-lock.json similarity index 100% rename from package-lock.json rename to src/package-lock.json diff --git a/package.json b/src/package.json similarity index 100% rename from package.json rename to src/package.json diff --git a/server.js b/src/server.js similarity index 98% rename from server.js rename to src/server.js index 48d5d4c..fdaeb58 100644 --- a/server.js +++ b/src/server.js @@ -112,7 +112,7 @@ const createServer = () => { * Used internally to refresh tokens automatically */ const refresh = () => { - config.authClient.refreshToken(credentials, scopes) + config.authClient.refreshToken(credentials, config.scopes) .then(creds => { credentials = creds; console.log( diff --git a/taskRunner.js b/src/taskRunner.js similarity index 100% rename from taskRunner.js rename to src/taskRunner.js diff --git a/watcher.js b/src/watcher.js similarity index 100% rename from watcher.js rename to src/watcher.js From a67cda8ae663c796aa200208c89d01ebc5283891 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Dec 2021 13:07:59 -0500 Subject: [PATCH 05/13] typescript --- .eslintrc.json | 9 ++- src/package-lock.json | 154 ++++++++++++++++++++++++++++++++++++++++++ src/package.json | 5 +- tsconfig.json | 103 ++++++++++++++++++++++++++++ 4 files changed, 267 insertions(+), 4 deletions(-) create mode 100644 tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json index e8840f5..d184586 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,10 +7,13 @@ "extends": [ "standard" ], + "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": 13 + "ecmaVersion": 12 }, + "plugins": [ + "@typescript-eslint" + ], "rules": { - "semi": [2, "always"] } -} +} \ No newline at end of file diff --git a/src/package-lock.json b/src/package-lock.json index 532e5d2..e11ebd3 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -16,6 +16,8 @@ "forge-apis": "^0.8.6" }, "devDependencies": { + "@types/express": "^4.17.13", + "@types/node": "^16.11.11", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.25.3", @@ -212,12 +214,88 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "node_modules/@types/body-parser": { + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", + "dev": true, + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.35", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", + "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/express": { + "version": "4.17.13", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", + "integrity": "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==", + "dev": true, + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.18", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.17.26", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.26.tgz", + "integrity": "sha512-zeu3tpouA043RHxW0gzRxwCHchMgftE8GArRsvYT0ByDMbn19olQHx5jLue0LxWY6iYtXb7rXmuVtSkhy9YZvQ==", + "dev": true, + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*" + } + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "node_modules/@types/mime": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", + "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", + "dev": true + }, + "node_modules/@types/node": { + "version": "16.11.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", + "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==", + "dev": true + }, + "node_modules/@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==", + "dev": true + }, + "node_modules/@types/range-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", + "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", + "dev": true + }, + "node_modules/@types/serve-static": { + "version": "1.13.10", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz", + "integrity": "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==", + "dev": true, + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, "node_modules/accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -3211,12 +3289,88 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "@types/body-parser": { + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.2.tgz", + "integrity": "sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==", + "dev": true, + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/connect": { + "version": "3.4.35", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", + "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/express": { + "version": "4.17.13", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", + "integrity": "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==", + "dev": true, + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.18", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.17.26", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.26.tgz", + "integrity": "sha512-zeu3tpouA043RHxW0gzRxwCHchMgftE8GArRsvYT0ByDMbn19olQHx5jLue0LxWY6iYtXb7rXmuVtSkhy9YZvQ==", + "dev": true, + "requires": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*" + } + }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "@types/mime": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", + "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", + "dev": true + }, + "@types/node": { + "version": "16.11.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", + "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==", + "dev": true + }, + "@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==", + "dev": true + }, + "@types/range-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", + "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", + "dev": true + }, + "@types/serve-static": { + "version": "1.13.10", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz", + "integrity": "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==", + "dev": true, + "requires": { + "@types/mime": "^1", + "@types/node": "*" + } + }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", diff --git a/src/package.json b/src/package.json index 543d5bc..e7e4718 100644 --- a/src/package.json +++ b/src/package.json @@ -5,7 +5,8 @@ "main": "server.js", "scripts": { "start": "node server.js", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "tsc": "tsc" }, "repository": { "type": "git", @@ -21,6 +22,8 @@ "forge-apis": "^0.8.6" }, "devDependencies": { + "@types/express": "^4.17.13", + "@types/node": "^16.11.11", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.25.3", diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d1c4369 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,103 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + + /* Projects */ + // "incremental": true, /* Enable incremental compilation */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ + // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "resolveJsonModule": true, /* Enable importing .json files */ + // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ + // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "outDir": "dist", + "sourceMap": true + } +} From 1f00759f2a0049d3ca173d6bc8395dcac89ec304 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Dec 2021 13:48:48 -0500 Subject: [PATCH 06/13] server -> ts --- environment.d.ts | 14 +++++ src/config.ts | 61 +++++++++++++++++++ src/package-lock.json | 61 ++++++++++++++++++- src/package.json | 5 +- src/server.ts | 132 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 environment.d.ts create mode 100644 src/config.ts create mode 100644 src/server.ts diff --git a/environment.d.ts b/environment.d.ts new file mode 100644 index 0000000..507be66 --- /dev/null +++ b/environment.d.ts @@ -0,0 +1,14 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + FORGE_CLIENT_ID: string; + FORGE_CLIENT_SECRET: string; + FORGE_CALLBACK_URL: string; + PORT: string; + } + } + } + + // If this file has no import/export statements (i.e. is a script) + // convert it into a module by adding an empty export statement. + export {} \ No newline at end of file diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..184e30e --- /dev/null +++ b/src/config.ts @@ -0,0 +1,61 @@ +/** + * Configures constants used in the other parts of this app + */ + +import { AuthClientThreeLegged } from 'forge-apis'; + +import * as dotenv from 'dotenv'; + +dotenv.config({path: '../.env'}); + +export const ForgeAuthClient = AuthClientThreeLegged; + +export const scopes: any = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write']; + + +// TODO: add production environment variables + +export const authClient = new ForgeAuthClient( + process.env.FORGE_CLIENT_ID, + process.env.FORGE_CLIENT_SECRET, + process.env.FORGE_CALLBACK_URL, + scopes, + true +); + +export const fileShareProjectID = "a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTExNTQ2Njg0NTI1MQ"; + +export const folderMap = { + gantry: { + fusionID: "urn:adsk.wipprod:fs.folder:co.IxiedfeBTOGg6NSIGQhXxQ", + local: "File Share/Gantry" + }, + lathe: { + fusionID: "urn:adsk.wipprod:fs.folder:co.FDWCeyBGQX2rv8xSNWo5lg", + local: "File Share/Lathe" + }, + mill: { + fusionID: "urn:adsk.wipprod:fs.folder:co.nEihcpHUSW-ZsVzU-__1iw", + local: "File Share/Mill" + }, + waterjet: { + fusionID: "urn:adsk.wipprod:fs.folder:co.vJLXAKGbQQayeljr-nwztQ", + local: "File Share/Waterjet" + } +}; + +export const port = process.env.PORT; +export const forgeClientId = process.env.FORGE_CLIENT_ID; +export const forgeClientSecret = process.env.FORGE_CLIENT_SECRET; +export const forgeCallbackURL = process.env.FORGE_CALLBACK_URL; + +// export = { +// authClient: authClient, +// scopes: scopes, +// projectID: fileShareProjectID, +// folderMap: folderMap, +// port: process.env.PORT, +// forgeClientId: process.env.FORGE_CLIENT_ID, +// forgeClientSecret: process.env.FORGE_CLIENT_SECRET, +// forgeCallbackURL: process.env.FORGE_CALLBACK_URL +// } \ No newline at end of file diff --git a/src/package-lock.json b/src/package-lock.json index e11ebd3..1956c63 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -16,13 +16,16 @@ "forge-apis": "^0.8.6" }, "devDependencies": { + "@types/dotenv": "^8.2.0", "@types/express": "^4.17.13", + "@types/forge-apis": "^0.8.2", "@types/node": "^16.11.11", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.25.3", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.1.1" + "eslint-plugin-promise": "^5.1.1", + "typescript": "^4.5.2" } }, "node_modules/@babel/code-frame": { @@ -233,6 +236,16 @@ "@types/node": "*" } }, + "node_modules/@types/dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw==", + "deprecated": "This is a stub types definition. dotenv provides its own type definitions, so you do not need this installed.", + "dev": true, + "dependencies": { + "dotenv": "*" + } + }, "node_modules/@types/express": { "version": "4.17.13", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", @@ -256,6 +269,15 @@ "@types/range-parser": "*" } }, + "node_modules/@types/forge-apis": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@types/forge-apis/-/forge-apis-0.8.2.tgz", + "integrity": "sha512-uY/BAv6fVbYmhrDFi0t5qCcuXXiipIwwLfUOt9is1ZhNU4k/YyeGNfTSTzxkvUDLN4iEwX3LCeSQVcZe+DbIkg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -3008,6 +3030,19 @@ "node": ">= 0.6" } }, + "node_modules/typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, "node_modules/unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", @@ -3308,6 +3343,15 @@ "@types/node": "*" } }, + "@types/dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/@types/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw==", + "dev": true, + "requires": { + "dotenv": "*" + } + }, "@types/express": { "version": "4.17.13", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", @@ -3331,6 +3375,15 @@ "@types/range-parser": "*" } }, + "@types/forge-apis": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@types/forge-apis/-/forge-apis-0.8.2.tgz", + "integrity": "sha512-uY/BAv6fVbYmhrDFi0t5qCcuXXiipIwwLfUOt9is1ZhNU4k/YyeGNfTSTzxkvUDLN4iEwX3LCeSQVcZe+DbIkg==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -5400,6 +5453,12 @@ "mime-types": "~2.1.24" } }, + "typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "dev": true + }, "unbox-primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", diff --git a/src/package.json b/src/package.json index e7e4718..b5fee7d 100644 --- a/src/package.json +++ b/src/package.json @@ -22,12 +22,15 @@ "forge-apis": "^0.8.6" }, "devDependencies": { + "@types/dotenv": "^8.2.0", "@types/express": "^4.17.13", + "@types/forge-apis": "^0.8.2", "@types/node": "^16.11.11", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.25.3", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^5.1.1" + "eslint-plugin-promise": "^5.1.1", + "typescript": "^4.5.2" } } diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..cc423d9 --- /dev/null +++ b/src/server.ts @@ -0,0 +1,132 @@ +import express from 'express'; +import * as config from './config'; + + +const ForgeAuthClient = require('forge-apis').AuthClientThreeLegged; +/** + * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 + * + * Authentication server used to perform 3-legged auth through browser. + * + * Uses environment variables: + * - FORGE_CLIENT_ID + * - FORGE CLIENT_SECRET + * - FORGE_CALLBACK_URL + * - PORT (defaults to 3000) + * + * These are all configured in config.js + * + */ + +let credentials: any = null; +let refreshTime: any = null; +let intervalID: NodeJS.Timeout; +const app = express(); + +/** + * Creates server with three endpoints: + * 1. /auth + * - navigate to login in to Autodesk and begin auth process + * 2. /callback + * - after consent screen, auth API will redirect headers + * 3. /credentials + * - will return credentials JSON object or null if there isn't one + * @returns express server object + */ +const createServer = () => { + + const PORT = config.port || 3000; + + if (config.forgeClientId == null || config.forgeClientSecret == null) { + console.error('Missing FORGE_CLIENT_ID or FORGE_CLIENT_SECRET env. variables.'); + return; + } + + // Endpoint to begin authentication process + app.get('/auth', function (req, res) { + console.log( + '\x1b[96mserver.js::createServer:', + '\x1b[0m/auth endpoint called' + ); + res.redirect(config.authClient.generateAuthUrl("")); + }); + + // Endpoint Forge redirects to after consent screen + app.get('/callback', function (req: any, res: any) { + config.authClient.getToken(req.query.code) + .then((creds) => { + credentials = creds; + refreshTime = creds.expires_in - 300; + res.send('Generated token: ' + credentials.access_token); + console.log( + '\x1b[92mserver.js::createServer:', + '\x1b[0m/callback reached, token generated' + ); + }) + .then(() => { + // sets refresh() function to run on an interval every 55 minutes + intervalID = setInterval(() => refresh(), refreshTime * 1000); // 55 seconds to ms + + // sets timeout for 13 days, before clearing refresh interval and clearing credentials + setTimeout(() => { + credentials = null; + clearInterval(intervalID); + console.log( + '\x1b[93mserver.js::createServer:', + '\x1b[0mRefresh token expiring, need to authenticate again' + ); + }, 13 * 24 * 3600 * 1000); // 13 days to ms + }) + .catch((err: any) => { + console.error(err); + res.send(err); + }); + }); + + // Endpoint for internal use, to get credentials from our auth server + app.get('/credentials', function (req, res) { + if (credentials) { + console.log( + '\x1b[96mserver.js::createServer:', + '\x1b[0m/credentials endpoint called, credentials returned' + ); + res.send(credentials); + } else { + console.log( + '\x1b[93mserver.js::createServer:', + '\x1b[0m/credentials endpoint called, no credentials found' + ); + res.send('Need to authenticate at localhost:3000/auth'); + } + }); + + // Default endpoint + app.use((err: any, req: any, res: any, next: any) => { + console.error(err); + res.status(err.statusCode).json(err); + }); + + const server = app.listen(config.port, () => { console.log(`Server listening on port ${PORT}`); }); + + return server; +} + +/** + * Used internally to refresh tokens automatically + */ +const refresh = () => { + config.authClient.refreshToken(credentials, config.scopes) + .then(creds => { + credentials = creds; + console.log( + '\x1b[92mserver.js::refresh:', + '\x1b[0mnew token generated from refresh token:' + ); + console.log(credentials); + }) + .catch(err => { + console.log(err); + }); +}; + +createServer(); \ No newline at end of file From f9b79dbe2c3fcfa5bdca1d1965fc20960e5063e3 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Dec 2021 13:55:17 -0500 Subject: [PATCH 07/13] cleanup --- src/server.ts | 7 +++---- tsconfig.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/server.ts b/src/server.ts index cc423d9..90909b9 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,8 +1,7 @@ -import express from 'express'; +import * as express from 'express'; import * as config from './config'; -const ForgeAuthClient = require('forge-apis').AuthClientThreeLegged; /** * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 * @@ -43,7 +42,7 @@ const createServer = () => { } // Endpoint to begin authentication process - app.get('/auth', function (req, res) { + app.get('/auth', function (req: any, res: any) { console.log( '\x1b[96mserver.js::createServer:', '\x1b[0m/auth endpoint called' @@ -84,7 +83,7 @@ const createServer = () => { }); // Endpoint for internal use, to get credentials from our auth server - app.get('/credentials', function (req, res) { + app.get('/credentials', function (req: any, res: any) { if (credentials) { console.log( '\x1b[96mserver.js::createServer:', diff --git a/tsconfig.json b/tsconfig.json index d1c4369..5377628 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -69,7 +69,7 @@ /* Interop Constraints */ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ + "esModuleInterop": false, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ From 3b8c3dec48dff735f2adc67dcdc27937e4f93cc9 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Dec 2021 15:08:16 -0500 Subject: [PATCH 08/13] js to ts --- .gitignore | 3 +- src/config.js | 36 -------- src/config.ts | 25 ++---- src/{downloader.js => downloader.ts} | 16 ++-- src/server.js | 129 --------------------------- src/server.ts | 4 +- src/{taskRunner.js => taskRunner.ts} | 33 +++---- src/{watcher.js => watcher.ts} | 16 ++-- tsconfig.json | 2 +- 9 files changed, 46 insertions(+), 218 deletions(-) delete mode 100644 src/config.js rename src/{downloader.js => downloader.ts} (60%) delete mode 100644 src/server.js rename src/{taskRunner.js => taskRunner.ts} (76%) rename src/{watcher.js => watcher.ts} (88%) diff --git a/.gitignore b/.gitignore index b7bdf70..777fa44 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ node_modules credentials.json -download_tests \ No newline at end of file +download_tests +dist \ No newline at end of file diff --git a/src/config.js b/src/config.js deleted file mode 100644 index d1b9c01..0000000 --- a/src/config.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Configures constants used in the other parts of this app - */ - -const dotenv = require('dotenv'); - -dotenv.config({path: '../.env'}); - -const ForgeAuthClient = require('forge-apis').AuthClientThreeLegged; - -const scopes = ['bucket:create', 'bucket:read', 'data:read', 'data:create', 'data:write']; - -const authClient = new ForgeAuthClient( - process.env.FORGE_CLIENT_ID, - process.env.FORGE_CLIENT_SECRET, - process.env.FORGE_CALLBACK_URL, - scopes, - true -); - -const folderIdMap = { - gantry: "GANTRY_FOLDER_ID", - lathe: "LATHE_FOLDER_ID", - mill: "MILL_FOLDER_ID", - waterjet: "WATERJET_FOLDER_ID" -}; - -module.exports = { - authClient: authClient, - scopes: scopes, - folderIdMap: folderIdMap, - port: process.env.PORT, - forgeClientId: process.env.FORGE_CLIENT_ID, - forgeClientSecret: process.env.FORGE_CLIENT_SECRET, - forgeCallbackURL: process.env.FORGE_CALLBACK_URL -} \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 184e30e..1ff8b44 100644 --- a/src/config.ts +++ b/src/config.ts @@ -23,39 +23,28 @@ export const authClient = new ForgeAuthClient( true ); -export const fileShareProjectID = "a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTExNTQ2Njg0NTI1MQ"; +export const projectID = "a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTExNTQ2Njg0NTI1MQ"; -export const folderMap = { +export const folderMap: any = { gantry: { fusionID: "urn:adsk.wipprod:fs.folder:co.IxiedfeBTOGg6NSIGQhXxQ", - local: "File Share/Gantry" + local: "../../File Share/Gantry" }, lathe: { fusionID: "urn:adsk.wipprod:fs.folder:co.FDWCeyBGQX2rv8xSNWo5lg", - local: "File Share/Lathe" + local: "../../File Share/Lathe" }, mill: { fusionID: "urn:adsk.wipprod:fs.folder:co.nEihcpHUSW-ZsVzU-__1iw", - local: "File Share/Mill" + local: "../../File Share/Mill" }, waterjet: { fusionID: "urn:adsk.wipprod:fs.folder:co.vJLXAKGbQQayeljr-nwztQ", - local: "File Share/Waterjet" + local: "../../File Share/Waterjet" } }; export const port = process.env.PORT; export const forgeClientId = process.env.FORGE_CLIENT_ID; export const forgeClientSecret = process.env.FORGE_CLIENT_SECRET; -export const forgeCallbackURL = process.env.FORGE_CALLBACK_URL; - -// export = { -// authClient: authClient, -// scopes: scopes, -// projectID: fileShareProjectID, -// folderMap: folderMap, -// port: process.env.PORT, -// forgeClientId: process.env.FORGE_CLIENT_ID, -// forgeClientSecret: process.env.FORGE_CLIENT_SECRET, -// forgeCallbackURL: process.env.FORGE_CALLBACK_URL -// } \ No newline at end of file +export const forgeCallbackURL = process.env.FORGE_CALLBACK_URL; \ No newline at end of file diff --git a/src/downloader.js b/src/downloader.ts similarity index 60% rename from src/downloader.js rename to src/downloader.ts index 35b3e2b..1d11fb5 100644 --- a/src/downloader.js +++ b/src/downloader.ts @@ -5,23 +5,23 @@ const config = require('./config'); const ObjectsApi = new ForgeSDK.ObjectsApi(); /** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/30/2021 + * Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021 * * Downloads a file by using the Forge SDK to make a GET request * on the storageLocation and then saves the file as `filename` under the `destination` directory - * @param {String} storageLocation - * @param {String} fileName - * @param {String} destination + * @param {string} storageLocation + * @param {string} fileName + * @param {string} destination * @param {Object} credentials */ -exports.download = (storageLocation, fileName, destination, credentials) => { +exports.download = (storageLocation: string, fileName: string, destination: string, credentials: any) => { ObjectsApi.getObject('wip.dm.prod', storageLocation, {}, config.authClient, credentials) - .then((res) => { + .then((res: any) => { console.log(res) - fs.writeFile(`./${destination}/${fileName}`, res.body) + fs.writeFile(`${__dirname}/${destination}/${fileName}`, res.body) }) - .catch((err) => { + .catch((err: any) => { console.log("error while processing " + storageLocation); console.log(err); }); diff --git a/src/server.js b/src/server.js deleted file mode 100644 index fdaeb58..0000000 --- a/src/server.js +++ /dev/null @@ -1,129 +0,0 @@ -const express = require('express'); -const config = require('./config'); - -/** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 - * - * Authentication server used to perform 3-legged auth through browser. - * - * Uses environment variables: - * - FORGE_CLIENT_ID - * - FORGE CLIENT_SECRET - * - FORGE_CALLBACK_URL - * - PORT (defaults to 3000) - * - * These are all configured in config.js - * - */ - -let credentials = null; -let refreshTime = null; -let intervalID = null; - -/** - * Creates server with three endpoints: - * 1. /auth - * - navigate to login in to Autodesk and begin auth process - * 2. /callback - * - after consent screen, auth API will redirect headers - * 3. /credentials - * - will return credentials JSON object or null if there isn't one - * @returns express server object - */ -const createServer = () => { - const app = express(); - const PORT = config.port || 3000; - - if (config.forgeClientId == null || config.forgeClientSecret == null) { - console.error('Missing FORGE_CLIENT_ID or FORGE_CLIENT_SECRET env. variables.'); - return; - } - - // Endpoint to begin authentication process - app.get('/auth', function (req, res) { - console.log( - '\x1b[96mserver.js::createServer:', - '\x1b[0m/auth endpoint called' - ); - res.redirect(config.authClient.generateAuthUrl()); - }); - - // Endpoint Forge redirects to after consent screen - app.get('/callback', function (req, res) { - config.authClient.getToken(req.query.code) - .then((creds) => { - credentials = creds; - refreshTime = creds.expires_in - 300; - res.send('Generated token: ' + credentials.access_token); - console.log( - '\x1b[92mserver.js::createServer:', - '\x1b[0m/callback reached, token generated' - ); - }) - .then(() => { - // sets refresh() function to run on an interval every 55 minutes - intervalID = setInterval(() => refresh(), refreshTime * 1000); // 55 seconds to ms - - // sets timeout for 13 days, before clearing refresh interval and clearing credentials - setTimeout(() => { - credentials = null; - clearInterval(intervalID); - console.log( - '\x1b[93mserver.js::createServer:', - '\x1b[0mRefresh token expiring, need to authenticate again' - ); - }, 13 * 24 * 3600 * 1000); // 13 days to ms - }) - .catch((err) => { - console.error(err); - res.send(err); - }); - }); - - // Endpoint for internal use, to get credentials from our auth server - app.get('/credentials', function (req, res) { - if (credentials) { - console.log( - '\x1b[96mserver.js::createServer:', - '\x1b[0m/credentials endpoint called, credentials returned' - ); - res.send(credentials); - } else { - console.log( - '\x1b[93mserver.js::createServer:', - '\x1b[0m/credentials endpoint called, no credentials found' - ); - res.send('Need to authenticate at localhost:3000/auth'); - } - }); - - // Default endpoint - app.use((err, req, res, next) => { - console.error(err); - res.status(err.statusCode).json(err); - }); - - const server = app.listen(config.port, () => { console.log(`Server listening on port ${PORT}`); }); - - return server; -} - -/** - * Used internally to refresh tokens automatically - */ -const refresh = () => { - config.authClient.refreshToken(credentials, config.scopes) - .then(creds => { - credentials = creds; - console.log( - '\x1b[92mserver.js::refresh:', - '\x1b[0mnew token generated from refresh token:' - ); - console.log(credentials); - }) - .catch(err => { - console.log(err); - }); -}; - -createServer(); \ No newline at end of file diff --git a/src/server.ts b/src/server.ts index 90909b9..2aa3001 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,9 +1,9 @@ -import * as express from 'express'; +import express = require('express'); import * as config from './config'; /** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/22/2021 + * Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021 * * Authentication server used to perform 3-legged auth through browser. * diff --git a/src/taskRunner.js b/src/taskRunner.ts similarity index 76% rename from src/taskRunner.js rename to src/taskRunner.ts index acb9ecb..cbd950d 100644 --- a/src/taskRunner.js +++ b/src/taskRunner.ts @@ -1,10 +1,11 @@ const axios = require('axios'); const watcher = require('./watcher'); const downloader = require('./downloader'); -const config = require('./config'); +import * as config from './config'; + /** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/30/2021 + * Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021 * * This file will be responsible for managing the watcher * as well as fetching the credentials from the server @@ -19,15 +20,17 @@ const projectID = "" // parse command line arguments from docker-compose to get folder ID -const folderID = config.folderIdMap[process.argv[2]]; -console.log(folderID); +const folderID = config.folderMap[process.argv[2]].fusionID; +const localDir = config.folderMap[process.argv[2]].local; + +console.log(folderID, localDir); -const adminProjectID = 'a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTEwODQ2NDQzMzk3Ng'; -const adminProjectTopFolder = 'urn:adsk.wipprod:fs.folder:co.ltuYad4ZTtieJLm6j3MGuA'; +// const adminProjectID = 'a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTEwODQ2NDQzMzk3Ng'; +// const adminProjectTopFolder = 'urn:adsk.wipprod:fs.folder:co.ltuYad4ZTtieJLm6j3MGuA'; -let credentials = null; -let initInterval = null; -let updateInterval = null; +let credentials: any = null; +let initInterval: any = null; +let updateInterval: any = null; /** * Sends GET request to get token from auth server @@ -41,7 +44,7 @@ const fetchToken = () => { method: 'GET', url: 'http://localhost:3000/credentials' }) - .then(res => { + .then((res: any) => { // console.log(res.data); if (Object.keys(res.data).length == 5) { credentials = res.data; @@ -57,7 +60,7 @@ const fetchToken = () => { ); } }) - .catch(err => { + .catch((err: any) => { console.log( '\x1b[91mtaskRunner.js::fetchToken:', '\x1b[0mError accessing localhost:3000/credentials' @@ -85,7 +88,7 @@ const getCredentials = () => { /** * Function to dispatch the watcher */ -const dispatchWatcher = async (interval) => { +const dispatchWatcher = async (interval: any) => { if (credentials === null) { console.log( '\x1b[93mtaskRunner.js::dispatchWatcher:', @@ -94,15 +97,15 @@ const dispatchWatcher = async (interval) => { return; } - const items = await watcher.watch(adminProjectID, adminProjectTopFolder, credentials, interval); + const items = await watcher.watch(config.projectID, folderID, credentials, interval); if (Object.keys(items).length == 0) { return; // no items to download } - for (index in items) { + for (var index in items) { // dispatch the downloader here - downloader.download(items[index].location, items[index].name, 'download_tests', credentials); + downloader.download(items[index].location, items[index].name, localDir, credentials); } }; diff --git a/src/watcher.js b/src/watcher.ts similarity index 88% rename from src/watcher.js rename to src/watcher.ts index a321e97..4824607 100644 --- a/src/watcher.js +++ b/src/watcher.ts @@ -1,19 +1,19 @@ const axios = require('axios'); /** - * Kevin Pan | pan261@purdue.edu | Last Modified: 11/30/2021 + * Kevin Pan | pan261@purdue.edu | Last Modified: 12/2/2021 * * Watches given folder id in the project, logs any files changed since * `interval` ms ago - * @param {String} projectId the project id - * @param {String} folderId the folder id + * @param {string} projectId the project id + * @param {string} folderId the folder id * @param {Object} credentials credentials for the call * @param {Integer} interval number of ms used to filter the date * if an interval is not passed, watcher will return all files in the given folder * * @return {Object} changedItems array of items changed that need to be downloaded */ -exports.watch = (projectID, folderID, credentials, interval) => { +exports.watch = (projectID: string, folderID: string, credentials: any, interval: any) => { let timeFilter = {}; if (interval) { @@ -34,10 +34,10 @@ exports.watch = (projectID, folderID, credentials, interval) => { }, params: timeFilter }) - .then(res => { + .then((res: any) => { return res.data.included; }) - .then(data => { + .then((data: any) => { if (data === undefined) { // no new files changed, return console.log( '\x1b[96mwatcher.js::watch:', @@ -45,7 +45,7 @@ exports.watch = (projectID, folderID, credentials, interval) => { return {}; } - let changedItems = {}; + let changedItems: any = {}; for (var index in data) { // console.log(data[index]); @@ -75,7 +75,7 @@ exports.watch = (projectID, folderID, credentials, interval) => { return changedItems; }) - .catch(err => { + .catch((err: any) => { console.log( '\x1b[91mwatcher.js::watch:', '\x1b[0mError accessing Forge folder contents API' diff --git a/tsconfig.json b/tsconfig.json index 5377628..3b05550 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -97,7 +97,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "outDir": "dist", + "outDir": "./src/dist", "sourceMap": true } } From 9053eca1aab747388d1ddb0fa6986210aa37293b Mon Sep 17 00:00:00 2001 From: pan261 Date: Tue, 7 Dec 2021 12:45:22 -0500 Subject: [PATCH 09/13] reorganized files --- .gitignore | 3 +- src/package-lock.json => package-lock.json | 351 ++++++++++----------- src/package.json => package.json | 4 +- tsconfig.json | 2 +- 4 files changed, 176 insertions(+), 184 deletions(-) rename src/package-lock.json => package-lock.json (96%) rename src/package.json => package.json (93%) diff --git a/.gitignore b/.gitignore index 777fa44..9565585 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ node_modules credentials.json download_tests -dist \ No newline at end of file +build +File Share \ No newline at end of file diff --git a/src/package-lock.json b/package-lock.json similarity index 96% rename from src/package-lock.json rename to package-lock.json index 1956c63..3f1ddbb 100644 --- a/src/package-lock.json +++ b/package-lock.json @@ -152,9 +152,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -189,9 +189,9 @@ } }, "node_modules/@humanwhocodes/config-array/node_modules/debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -291,9 +291,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.11.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", - "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==", + "version": "16.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", + "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==", "dev": true }, "node_modules/@types/qs": { @@ -450,9 +450,9 @@ } }, "node_modules/asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", "dependencies": { "safer-buffer": "~2.1.0" } @@ -534,12 +534,12 @@ "node": ">= 0.8" } }, - "node_modules/body-parser/node_modules/qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "node_modules/body-parser/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "engines": { - "node": ">=0.6" + "node": ">= 0.6" } }, "node_modules/brace-expansion": { @@ -649,11 +649,6 @@ "node": ">= 0.6" } }, - "node_modules/content-disposition/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, "node_modules/content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", @@ -697,14 +692,6 @@ "node": ">= 0.8" } }, - "node_modules/cookies/node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "engines": { - "node": ">= 0.8" - } - }, "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -770,11 +757,11 @@ } }, "node_modules/depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", "engines": { - "node": ">= 0.6" + "node": ">= 0.8" } }, "node_modules/destroy": { @@ -1144,9 +1131,9 @@ } }, "node_modules/eslint-plugin-promise": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.1.1.tgz", - "integrity": "sha512-XgdcdyNzHfmlQyweOPTxmc7pIsS6dE4MvwhXWMQ2Dxs1XAL2GJDilUsjWen6TWik0aSI+zD/PqocZBblcm9rdA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.2.0.tgz", + "integrity": "sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==", "dev": true, "engines": { "node": "^10.12.0 || >=12.0.0" @@ -1202,9 +1189,9 @@ } }, "node_modules/eslint/node_modules/debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "dependencies": { "ms": "2.1.2" @@ -1368,19 +1355,14 @@ "node": ">= 0.10.0" } }, - "node_modules/express/node_modules/qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "node_modules/express/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", "engines": { - "node": ">=0.6" + "node": ">= 0.6" } }, - "node_modules/express/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, "node_modules/extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -1501,7 +1483,6 @@ "version": "0.8.6", "resolved": "https://registry.npmjs.org/forge-apis/-/forge-apis-0.8.6.tgz", "integrity": "sha512-zDmIq9qaiELbZ2fNW7tJ8yydqMo/KY/oSwoK/2DSMd5EpQ73vAZGz0aG/fXowi2D/rfcFLhUH3h8w9ozwnVLtg==", - "license": "Apache-2.0", "dependencies": { "request": "^2.88.2" }, @@ -1734,6 +1715,14 @@ "node": ">= 0.6" } }, + "node_modules/http-errors/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -2062,9 +2051,9 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, "node_modules/json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" }, "node_modules/json-schema-traverse": { "version": "0.4.1", @@ -2095,17 +2084,17 @@ } }, "node_modules/jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "engines": [ - "node >=0.6.0" - ], + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "dependencies": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", - "json-schema": "0.2.3", + "json-schema": "0.4.0", "verror": "1.10.0" + }, + "engines": { + "node": ">=0.6.0" } }, "node_modules/keygrip": { @@ -2202,19 +2191,19 @@ } }, "node_modules/mime-db": { - "version": "1.50.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.50.0.tgz", - "integrity": "sha512-9tMZCDlYHqeERXEHO9f/hKfNXhre5dK2eE/krIvUjZbS2KPcqGDfNShIWS1uW9XOTKQKqK6qbeOci18rbfW77A==", + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { - "version": "2.1.33", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.33.tgz", - "integrity": "sha512-plLElXp7pRDd0bNZHw+nMd52vRYjLwQjygaNg7ddJ2uJtTlmnTCjWuPKxVu6//AdaRuME84SvLW91sIkBqGT0g==", + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", "dependencies": { - "mime-db": "1.50.0" + "mime-db": "1.51.0" }, "engines": { "node": ">= 0.6" @@ -2266,9 +2255,9 @@ } }, "node_modules/object-inspect": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", - "integrity": "sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.1.tgz", + "integrity": "sha512-If7BjFlpkzzBeV1cqgT3OSWT3azyoxDGajR+iGnFBfVV2EWyDyWaZZW2ERDjUaY2QM8i5jI3Sj7mhsM4DDAqWA==", "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2515,9 +2504,9 @@ } }, "node_modules/qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", "engines": { "node": ">=0.6" } @@ -2587,6 +2576,14 @@ "node": ">= 6" } }, + "node_modules/request/node_modules/qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -2634,23 +2631,9 @@ } }, "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/safer-buffer": { "version": "2.1.2", @@ -2695,6 +2678,14 @@ "node": ">= 0.8.0" } }, + "node_modules/send/node_modules/depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/send/node_modules/ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -2895,9 +2886,9 @@ } }, "node_modules/table": { - "version": "6.7.3", - "resolved": "https://registry.npmjs.org/table/-/table-6.7.3.tgz", - "integrity": "sha512-5DkIxeA7XERBqMwJq0aHZOdMadBx4e6eDoFRuyT5VR82J0Ycg2DwM6GfA/EQAhJ+toRTaS1lIdSQCqgrmhPnlw==", + "version": "6.7.5", + "resolved": "https://registry.npmjs.org/table/-/table-6.7.5.tgz", + "integrity": "sha512-LFNeryOqiQHqCVKzhkymKwt6ozeRhlm8IL1mE8rNUurkir4heF6PzMyRgaTa4tlyPTGGgXuvVOF/OLWiH09Lqw==", "dev": true, "dependencies": { "ajv": "^8.0.1", @@ -2911,9 +2902,9 @@ } }, "node_modules/table/node_modules/ajv": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.8.1.tgz", - "integrity": "sha512-6CiMNDrzv0ZR916u2T+iRunnD60uWmNn8SkdB44/6stVORUg0aAkWO7PkOhpCmjmW8f2I/G/xnowD66fxGyQJg==", + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.8.2.tgz", + "integrity": "sha512-x9VuX+R/jcFj1DHo/fCp99esgGDWiHENrKxaCENuCxpoMCmAt/COCGVDwA7kleEpEzJjDnvh3yGoOuLu0Dtllw==", "dev": true, "dependencies": { "fast-deep-equal": "^3.1.1", @@ -2959,9 +2950,9 @@ } }, "node_modules/tsconfig-paths": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.11.0.tgz", - "integrity": "sha512-7ecdYDnIdmv639mmDwslG6KQg1Z9STTz1j7Gcz0xa+nshh/gKDAHcPxRbWOsA3SPp0tXP2leTcY9Kw+NAkfZzA==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz", + "integrity": "sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg==", "dev": true, "dependencies": { "@types/json5": "^0.0.29", @@ -3274,9 +3265,9 @@ }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -3302,9 +3293,9 @@ }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -3397,9 +3388,9 @@ "dev": true }, "@types/node": { - "version": "16.11.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.11.tgz", - "integrity": "sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==", + "version": "16.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", + "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==", "dev": true }, "@types/qs": { @@ -3517,9 +3508,9 @@ } }, "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", "requires": { "safer-buffer": "~2.1.0" } @@ -3589,10 +3580,10 @@ "type-is": "~1.6.17" }, "dependencies": { - "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" } } }, @@ -3677,13 +3668,6 @@ "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", "requires": { "safe-buffer": "5.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - } } }, "content-type": { @@ -3718,13 +3702,6 @@ "requires": { "depd": "~2.0.0", "keygrip": "~1.1.0" - }, - "dependencies": { - "depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" - } } }, "core-util-is": { @@ -3780,9 +3757,9 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" }, "destroy": { "version": "1.0.4", @@ -3936,9 +3913,9 @@ }, "dependencies": { "debug": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", - "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", "dev": true, "requires": { "ms": "2.1.2" @@ -4085,9 +4062,9 @@ } }, "eslint-plugin-promise": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.1.1.tgz", - "integrity": "sha512-XgdcdyNzHfmlQyweOPTxmc7pIsS6dE4MvwhXWMQ2Dxs1XAL2GJDilUsjWen6TWik0aSI+zD/PqocZBblcm9rdA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.2.0.tgz", + "integrity": "sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==", "dev": true, "requires": {} }, @@ -4237,15 +4214,10 @@ "vary": "~1.1.2" }, "dependencies": { - "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" } } }, @@ -4500,6 +4472,13 @@ "setprototypeof": "1.1.1", "statuses": ">= 1.5.0 < 2", "toidentifier": "1.0.0" + }, + "dependencies": { + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + } } }, "http-signature": { @@ -4733,9 +4712,9 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" }, "json-schema-traverse": { "version": "0.4.1", @@ -4763,13 +4742,13 @@ } }, "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", "requires": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", - "json-schema": "0.2.3", + "json-schema": "0.4.0", "verror": "1.10.0" } }, @@ -4843,16 +4822,16 @@ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" }, "mime-db": { - "version": "1.50.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.50.0.tgz", - "integrity": "sha512-9tMZCDlYHqeERXEHO9f/hKfNXhre5dK2eE/krIvUjZbS2KPcqGDfNShIWS1uW9XOTKQKqK6qbeOci18rbfW77A==" + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" }, "mime-types": { - "version": "2.1.33", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.33.tgz", - "integrity": "sha512-plLElXp7pRDd0bNZHw+nMd52vRYjLwQjygaNg7ddJ2uJtTlmnTCjWuPKxVu6//AdaRuME84SvLW91sIkBqGT0g==", + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", "requires": { - "mime-db": "1.50.0" + "mime-db": "1.51.0" } }, "minimatch": { @@ -4892,9 +4871,9 @@ "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, "object-inspect": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.0.tgz", - "integrity": "sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.1.tgz", + "integrity": "sha512-If7BjFlpkzzBeV1cqgT3OSWT3azyoxDGajR+iGnFBfVV2EWyDyWaZZW2ERDjUaY2QM8i5jI3Sj7mhsM4DDAqWA==", "dev": true }, "object-keys": { @@ -5075,9 +5054,9 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" }, "qs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" }, "range-parser": { "version": "1.2.1", @@ -5126,6 +5105,13 @@ "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" + }, + "dependencies": { + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + } } }, "require-from-string": { @@ -5160,9 +5146,9 @@ } }, "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safer-buffer": { "version": "2.1.2", @@ -5198,6 +5184,11 @@ "statuses": "~1.5.0" }, "dependencies": { + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -5347,9 +5338,9 @@ } }, "table": { - "version": "6.7.3", - "resolved": "https://registry.npmjs.org/table/-/table-6.7.3.tgz", - "integrity": "sha512-5DkIxeA7XERBqMwJq0aHZOdMadBx4e6eDoFRuyT5VR82J0Ycg2DwM6GfA/EQAhJ+toRTaS1lIdSQCqgrmhPnlw==", + "version": "6.7.5", + "resolved": "https://registry.npmjs.org/table/-/table-6.7.5.tgz", + "integrity": "sha512-LFNeryOqiQHqCVKzhkymKwt6ozeRhlm8IL1mE8rNUurkir4heF6PzMyRgaTa4tlyPTGGgXuvVOF/OLWiH09Lqw==", "dev": true, "requires": { "ajv": "^8.0.1", @@ -5360,9 +5351,9 @@ }, "dependencies": { "ajv": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.8.1.tgz", - "integrity": "sha512-6CiMNDrzv0ZR916u2T+iRunnD60uWmNn8SkdB44/6stVORUg0aAkWO7PkOhpCmjmW8f2I/G/xnowD66fxGyQJg==", + "version": "8.8.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.8.2.tgz", + "integrity": "sha512-x9VuX+R/jcFj1DHo/fCp99esgGDWiHENrKxaCENuCxpoMCmAt/COCGVDwA7kleEpEzJjDnvh3yGoOuLu0Dtllw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -5400,9 +5391,9 @@ } }, "tsconfig-paths": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.11.0.tgz", - "integrity": "sha512-7ecdYDnIdmv639mmDwslG6KQg1Z9STTz1j7Gcz0xa+nshh/gKDAHcPxRbWOsA3SPp0tXP2leTcY9Kw+NAkfZzA==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz", + "integrity": "sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg==", "dev": true, "requires": { "@types/json5": "^0.0.29", diff --git a/src/package.json b/package.json similarity index 93% rename from src/package.json rename to package.json index b5fee7d..cc46461 100644 --- a/src/package.json +++ b/package.json @@ -2,9 +2,9 @@ "name": "fusionfilesync", "description": "", "version": "1.0.0", - "main": "server.js", + "main": "/src/server.js", "scripts": { - "start": "node server.js", + "start": "node /src/server.js", "test": "echo \"Error: no test specified\" && exit 1", "tsc": "tsc" }, diff --git a/tsconfig.json b/tsconfig.json index 3b05550..0b315b7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -97,7 +97,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - "outDir": "./src/dist", + "outDir": "./src/build", "sourceMap": true } } From b1c4a533d170787074c4c276d7bb37385ad5b617 Mon Sep 17 00:00:00 2001 From: pan261 Date: Tue, 7 Dec 2021 13:12:56 -0500 Subject: [PATCH 10/13] docker-compose support --- src/Dockerfile => Dockerfile | 2 +- docker-compose.yml | 46 +++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 7 deletions(-) rename src/Dockerfile => Dockerfile (78%) diff --git a/src/Dockerfile b/Dockerfile similarity index 78% rename from src/Dockerfile rename to Dockerfile index 3eb3686..c2bebc1 100644 --- a/src/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ FROM node:16 WORKDIR /ffs/ COPY package.json ./ RUN npm install -COPY . ./ \ No newline at end of file +COPY /src/build ./ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 9b43816..20330fe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,24 +1,58 @@ version: "3.8" + services: auth_server: build: - context: ./src + context: . dockerfile: Dockerfile env_file: ./.env volumes: - - ./src:/ffs/ + - ./src/build:/ffs/ - /ffs/node_modules ports: - "3000:3000" command: "node server.js" - task_runner_1: + task_runner_gantry: + build: + context: . + dockerfile: Dockerfile + env_file: ./.env + volumes: + - ./src/build:/ffs/ + - /ffs/node_modules + network_mode: host + command: "node taskRunner.js gantry" + + task_runner_lathe: + build: + context: . + dockerfile: Dockerfile + env_file: ./.env + volumes: + - ./src/build:/ffs/ + - /ffs/node_modules + network_mode: host + command: "node taskRunner.js lathe" + + task_runner_mill: + build: + context: . + dockerfile: Dockerfile + env_file: ./.env + volumes: + - ./src/build:/ffs/ + - /ffs/node_modules + network_mode: host + command: "node taskRunner.js mill" + + task_runner_waterjet: build: - context: ./src + context: . dockerfile: Dockerfile env_file: ./.env volumes: - - ./src:/ffs/ + - ./src/build:/ffs/ - /ffs/node_modules network_mode: host - command: "node taskRunner.js lathe" \ No newline at end of file + command: "node taskRunner.js waterjet" \ No newline at end of file From d96b2a1398a783a2d3b20b07d4aebc6c319986f0 Mon Sep 17 00:00:00 2001 From: pan261 Date: Tue, 7 Dec 2021 21:52:57 -0500 Subject: [PATCH 11/13] added docker support --- .gitignore | 2 +- docker-compose.yml | 61 +++++++++++++++++++++++----------------------- src/config.ts | 8 +++--- src/downloader.ts | 2 +- src/taskRunner.ts | 18 +++++++++++++- 5 files changed, 54 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 9565585..ccb9a92 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ node_modules credentials.json download_tests build -File Share \ No newline at end of file +FileShare \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 20330fe..f5fa928 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,38 +21,39 @@ services: volumes: - ./src/build:/ffs/ - /ffs/node_modules + - ./FileShare/Gantry:/ffs/FileShare/Gantry network_mode: host command: "node taskRunner.js gantry" - task_runner_lathe: - build: - context: . - dockerfile: Dockerfile - env_file: ./.env - volumes: - - ./src/build:/ffs/ - - /ffs/node_modules - network_mode: host - command: "node taskRunner.js lathe" + # task_runner_lathe: + # build: + # context: . + # dockerfile: Dockerfile + # env_file: ./.env + # volumes: + # - ./src/build:/ffs/ + # - /ffs/node_modules + # network_mode: host + # command: "node taskRunner.js lathe" - task_runner_mill: - build: - context: . - dockerfile: Dockerfile - env_file: ./.env - volumes: - - ./src/build:/ffs/ - - /ffs/node_modules - network_mode: host - command: "node taskRunner.js mill" + # task_runner_mill: + # build: + # context: . + # dockerfile: Dockerfile + # env_file: ./.env + # volumes: + # - ./src/build:/ffs/ + # - /ffs/node_modules + # network_mode: host + # command: "node taskRunner.js mill" - task_runner_waterjet: - build: - context: . - dockerfile: Dockerfile - env_file: ./.env - volumes: - - ./src/build:/ffs/ - - /ffs/node_modules - network_mode: host - command: "node taskRunner.js waterjet" \ No newline at end of file + # task_runner_waterjet: + # build: + # context: . + # dockerfile: Dockerfile + # env_file: ./.env + # volumes: + # - ./src/build:/ffs/ + # - /ffs/node_modules + # network_mode: host + # command: "node taskRunner.js waterjet" \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 1ff8b44..3675aa9 100644 --- a/src/config.ts +++ b/src/config.ts @@ -28,19 +28,19 @@ export const projectID = "a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTExNTQ2Njg0NTI1MQ"; export const folderMap: any = { gantry: { fusionID: "urn:adsk.wipprod:fs.folder:co.IxiedfeBTOGg6NSIGQhXxQ", - local: "../../File Share/Gantry" + local: "/Gantry" }, lathe: { fusionID: "urn:adsk.wipprod:fs.folder:co.FDWCeyBGQX2rv8xSNWo5lg", - local: "../../File Share/Lathe" + local: "/Lathe" }, mill: { fusionID: "urn:adsk.wipprod:fs.folder:co.nEihcpHUSW-ZsVzU-__1iw", - local: "../../File Share/Mill" + local: "/Mill" }, waterjet: { fusionID: "urn:adsk.wipprod:fs.folder:co.vJLXAKGbQQayeljr-nwztQ", - local: "../../File Share/Waterjet" + local: "/Waterjet" } }; diff --git a/src/downloader.ts b/src/downloader.ts index 1d11fb5..144a167 100644 --- a/src/downloader.ts +++ b/src/downloader.ts @@ -19,7 +19,7 @@ exports.download = (storageLocation: string, fileName: string, destination: stri ObjectsApi.getObject('wip.dm.prod', storageLocation, {}, config.authClient, credentials) .then((res: any) => { console.log(res) - fs.writeFile(`${__dirname}/${destination}/${fileName}`, res.body) + fs.writeFile(`${destination}/${fileName}`, res.body) }) .catch((err: any) => { console.log("error while processing " + storageLocation); diff --git a/src/taskRunner.ts b/src/taskRunner.ts index cbd950d..9deb503 100644 --- a/src/taskRunner.ts +++ b/src/taskRunner.ts @@ -1,6 +1,7 @@ const axios = require('axios'); const watcher = require('./watcher'); const downloader = require('./downloader'); +const fs = require('fs'); import * as config from './config'; @@ -21,10 +22,25 @@ const projectID = "" // parse command line arguments from docker-compose to get folder ID const folderID = config.folderMap[process.argv[2]].fusionID; -const localDir = config.folderMap[process.argv[2]].local; +const localPath = config.folderMap[process.argv[2]].local; +const localRootDir = './FileShare'; +const localDir = localRootDir + localPath; console.log(folderID, localDir); +if (!fs.existsSync(localDir)) { + console.log("Local directory:", localDir, "not found, creating it now"); + fs.mkdirSync(localDir, {recursive: true}); +} + +fs.writeFileSync(`${__dirname}/FileShare/Gantry/test.txt`, 'hello', (err: any) => { + if (err) + console.log(err); + else { + console.log('file written') + } +}); + // const adminProjectID = 'a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTEwODQ2NDQzMzk3Ng'; // const adminProjectTopFolder = 'urn:adsk.wipprod:fs.folder:co.ltuYad4ZTtieJLm6j3MGuA'; From 48c4828bd2c4a6b3336f434ff42022f5337fe49d Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 9 Dec 2021 13:02:27 -0500 Subject: [PATCH 12/13] configured docker with environment variables --- docker-compose.yml | 67 ++++++++++++++++++++++++---------------------- src/config.ts | 1 + src/taskRunner.ts | 19 +++++++------ 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f5fa928..1f1d65e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - ./src/build:/ffs/ - /ffs/node_modules ports: - - "3000:3000" + - ${PORT}:${PORT} command: "node server.js" task_runner_gantry: @@ -21,39 +21,42 @@ services: volumes: - ./src/build:/ffs/ - /ffs/node_modules - - ./FileShare/Gantry:/ffs/FileShare/Gantry + - ${LOCAL_DIR_GANTRY}:/ffs/FileShare/Gantry network_mode: host command: "node taskRunner.js gantry" - # task_runner_lathe: - # build: - # context: . - # dockerfile: Dockerfile - # env_file: ./.env - # volumes: - # - ./src/build:/ffs/ - # - /ffs/node_modules - # network_mode: host - # command: "node taskRunner.js lathe" + task_runner_lathe: + build: + context: . + dockerfile: Dockerfile + env_file: ./.env + volumes: + - ./src/build:/ffs/ + - /ffs/node_modules + - ${LOCAL_DIR_LATHE}:/ffs/FileShare/Lathe + network_mode: host + command: "node taskRunner.js lathe" - # task_runner_mill: - # build: - # context: . - # dockerfile: Dockerfile - # env_file: ./.env - # volumes: - # - ./src/build:/ffs/ - # - /ffs/node_modules - # network_mode: host - # command: "node taskRunner.js mill" + task_runner_mill: + build: + context: . + dockerfile: Dockerfile + env_file: ./.env + volumes: + - ./src/build:/ffs/ + - /ffs/node_modules + - ${LOCAL_DIR_MILL}:/ffs/FileShare/Mill + network_mode: host + command: "node taskRunner.js mill" - # task_runner_waterjet: - # build: - # context: . - # dockerfile: Dockerfile - # env_file: ./.env - # volumes: - # - ./src/build:/ffs/ - # - /ffs/node_modules - # network_mode: host - # command: "node taskRunner.js waterjet" \ No newline at end of file + task_runner_waterjet: + build: + context: . + dockerfile: Dockerfile + env_file: ./.env + volumes: + - ./src/build:/ffs/ + - /ffs/node_modules + - ${LOCAL_DIR_WATERJET}:/ffs/FileShare/Waterjet + network_mode: host + command: "node taskRunner.js waterjet" \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 3675aa9..51e3beb 100644 --- a/src/config.ts +++ b/src/config.ts @@ -25,6 +25,7 @@ export const authClient = new ForgeAuthClient( export const projectID = "a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTExNTQ2Njg0NTI1MQ"; +// The local fields are only for internal/container use, host paths are specified in the environment export const folderMap: any = { gantry: { fusionID: "urn:adsk.wipprod:fs.folder:co.IxiedfeBTOGg6NSIGQhXxQ", diff --git a/src/taskRunner.ts b/src/taskRunner.ts index 9deb503..2744e1e 100644 --- a/src/taskRunner.ts +++ b/src/taskRunner.ts @@ -23,8 +23,7 @@ const projectID = "" const folderID = config.folderMap[process.argv[2]].fusionID; const localPath = config.folderMap[process.argv[2]].local; -const localRootDir = './FileShare'; -const localDir = localRootDir + localPath; +const localDir = '/FileShare' + localPath; console.log(folderID, localDir); @@ -33,13 +32,13 @@ if (!fs.existsSync(localDir)) { fs.mkdirSync(localDir, {recursive: true}); } -fs.writeFileSync(`${__dirname}/FileShare/Gantry/test.txt`, 'hello', (err: any) => { - if (err) - console.log(err); - else { - console.log('file written') - } -}); +// fs.writeFileSync(`${__dirname}/FileShare/Gantry/test.txt`, 'hello', (err: any) => { +// if (err) +// console.log(err); +// else { +// console.log('file written') +// } +// }); // const adminProjectID = 'a.YnVzaW5lc3M6cHVyZHVlMjY5NiMyMDIxMTEwODQ2NDQzMzk3Ng'; // const adminProjectTopFolder = 'urn:adsk.wipprod:fs.folder:co.ltuYad4ZTtieJLm6j3MGuA'; @@ -121,7 +120,7 @@ const dispatchWatcher = async (interval: any) => { for (var index in items) { // dispatch the downloader here - downloader.download(items[index].location, items[index].name, localDir, credentials); + downloader.download(items[index].location, items[index].name, __dirname + '/' + localDir, credentials); } }; From e1db79a4f6cbf3876ff0c955eb17c5bb7f2eef31 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 9 Dec 2021 13:19:01 -0500 Subject: [PATCH 13/13] fixed paths --- src/taskRunner.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/taskRunner.ts b/src/taskRunner.ts index 2744e1e..1e4b9ec 100644 --- a/src/taskRunner.ts +++ b/src/taskRunner.ts @@ -23,7 +23,7 @@ const projectID = "" const folderID = config.folderMap[process.argv[2]].fusionID; const localPath = config.folderMap[process.argv[2]].local; -const localDir = '/FileShare' + localPath; +const localDir = __dirname + '/FileShare' + localPath; console.log(folderID, localDir); @@ -32,7 +32,7 @@ if (!fs.existsSync(localDir)) { fs.mkdirSync(localDir, {recursive: true}); } -// fs.writeFileSync(`${__dirname}/FileShare/Gantry/test.txt`, 'hello', (err: any) => { +// fs.writeFileSync(`${localDir}/test.txt`, 'hello', (err: any) => { // if (err) // console.log(err); // else {