From 191646b7eefddec15f6dde23f8b823dcd91c0b15 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 25 Jun 2021 17:14:23 +0100 Subject: [PATCH] Removing use of the arguments[0] as they don't mesh well with TS. --- packages/server/package.json | 2 +- packages/server/src/db/linkedRows/index.js | 33 ++++++++++--------- .../server/src/db/linkedRows/linkUtils.js | 23 ++++++------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index ff0344fb87..299262466e 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/Budibase/budibase.git" }, "scripts": { - "build": "tsc && mv dist/src/* dist/ && rmdir dist/src/", + "build": "rm -r dist/ && tsc && mv dist/src/* dist/ && rmdir dist/src/", "test": "jest --coverage --maxWorkers=2", "test:watch": "jest --watch", "build:docker": "docker build . -t app-service", diff --git a/packages/server/src/db/linkedRows/index.js b/packages/server/src/db/linkedRows/index.js index b4bd8711a2..610a424eaf 100644 --- a/packages/server/src/db/linkedRows/index.js +++ b/packages/server/src/db/linkedRows/index.js @@ -87,33 +87,34 @@ async function getFullLinkedDocs(appId, links) { /** * Update link documents for a row or table - this is to be called by the API controller when a change is occurring. - * @param {string} eventType states what type of change which is occurring, means this can be expanded upon in the + * @param {string} args.eventType states what type of change which is occurring, means this can be expanded upon in the * future quite easily (all updates go through one function). - * @param {string} appId The ID of the instance in which the change is occurring. - * @param {string} tableId The ID of the of the table which is being changed. - * @param {object|null} row The row which is changing, e.g. created, updated or deleted. - * @param {object|null} table If the table has already been retrieved this can be used to reduce database gets. - * @param {object|null} oldTable If the table is being updated then the old table can be provided for differencing. + * @param {string} args.appId The ID of the instance in which the change is occurring. + * @param {string} args.tableId The ID of the of the table which is being changed. + * @param {object|null} args.row The row which is changing, e.g. created, updated or deleted. + * @param {object|null} args.table If the table has already been retrieved this can be used to reduce database gets. + * @param {object|null} args.oldTable If the table is being updated then the old table can be provided for differencing. * @returns {Promise} When the update is complete this will respond successfully. Returns the row for * row operations and the table for table operations. */ -exports.updateLinks = async function ({ - eventType, - appId, - row, - tableId, - table, - oldTable, -}) { +exports.updateLinks = async function (args) { + const { + eventType, + appId, + row, + tableId, + table, + oldTable, + } = args const baseReturnObj = row == null ? table : row if (appId == null) { throw "Cannot operate without an instance ID." } // make sure table ID is set if (tableId == null && table != null) { - arguments[0].tableId = table._id + args.tableId = table._id } - let linkController = new LinkController(arguments[0]) + let linkController = new LinkController(args) try { if ( !(await linkController.doesTableHaveLinkedFields()) && diff --git a/packages/server/src/db/linkedRows/linkUtils.js b/packages/server/src/db/linkedRows/linkUtils.js index fc3e71b8d9..e7887669f8 100644 --- a/packages/server/src/db/linkedRows/linkUtils.js +++ b/packages/server/src/db/linkedRows/linkUtils.js @@ -17,24 +17,25 @@ exports.createLinkView = createLinkView /** * Gets the linking documents, not the linked documents themselves. - * @param {string} appId The instance in which we are searching for linked rows. - * @param {string} tableId The table which we are searching for linked rows against. - * @param {string|null} fieldName The name of column/field which is being altered, only looking for + * @param {string} args.appId The instance in which we are searching for linked rows. + * @param {string} args.tableId The table which we are searching for linked rows against. + * @param {string|null} args.fieldName The name of column/field which is being altered, only looking for * linking documents that are related to it. If this is not specified then the table level will be assumed. - * @param {string|null} rowId The ID of the row which we want to find linking documents for - + * @param {string|null} args.rowId The ID of the row which we want to find linking documents for - * if this is not specified then it will assume table or field level depending on whether the * field name has been specified. - * @param {boolean|null} includeDocs whether to include docs in the response call, this is considerably slower so only + * @param {boolean|null} args.includeDocs whether to include docs in the response call, this is considerably slower so only * use this if actually interested in the docs themselves. * @returns {Promise} This will return an array of the linking documents that were found * (if any). */ -exports.getLinkDocuments = async function ({ - appId, - tableId, - rowId, - includeDocs, -}) { +exports.getLinkDocuments = async function (args) { + const { + appId, + tableId, + rowId, + includeDocs, + } = args const db = new CouchDB(appId) let params if (rowId != null) {