diff --git a/packages/nodes-base/nodes/Coda/Coda.node.ts b/packages/nodes-base/nodes/Coda/Coda.node.ts index a2946e71f4..04d611aa53 100644 --- a/packages/nodes-base/nodes/Coda/Coda.node.ts +++ b/packages/nodes-base/nodes/Coda/Coda.node.ts @@ -37,7 +37,7 @@ export class Coda implements INodeType { icon: 'file:coda.png', group: ['output'], version: 1, - subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}', + subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Consume Coda Beta API', defaults: { name: 'Coda', @@ -58,9 +58,9 @@ export class Coda implements INodeType { type: 'options', options: [ { - name: 'Table', - value: 'table', - description: `Access data of tables in documents.`, + name: 'Control', + value: 'control', + description: 'Controls provide a user-friendly way to input a value that can affect other parts of the doc.', }, { name: 'Formula', @@ -68,9 +68,9 @@ export class Coda implements INodeType { description: 'Formulas can be great for performing one-off computations', }, { - name: 'Control', - value: 'control', - description: 'Controls provide a user-friendly way to input a value that can affect other parts of the doc.', + name: 'Table', + value: 'table', + description: `Access data of tables in documents.`, }, { name: 'View', @@ -99,12 +99,7 @@ export class Coda implements INodeType { async getDocs(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const qs = {}; - let docs; - try { - docs = await codaApiRequestAllItems.call(this,'items', 'GET', `/docs`, {}, qs); - } catch (err) { - throw new Error(`Coda Error: ${err}`); - } + const docs = await codaApiRequestAllItems.call(this,'items', 'GET', `/docs`, {}, qs); for (const doc of docs) { const docName = doc.name; const docId = doc.id; @@ -119,15 +114,10 @@ export class Coda implements INodeType { // select them easily async getTables(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - let tables; const docId = this.getCurrentNodeParameter('docId'); - try { - tables = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables`, {}); - } catch (err) { - throw new Error(`Coda Error: ${err}`); - } + const tables = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables`, {}); for (const table of tables) { const tableName = table.name; const tableId = table.id; @@ -142,16 +132,11 @@ export class Coda implements INodeType { // select them easily async getColumns(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - let columns; const docId = this.getCurrentNodeParameter('docId'); const tableId = this.getCurrentNodeParameter('tableId'); - try { - columns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables/${tableId}/columns`, {}); - } catch (err) { - throw new Error(`Coda Error: ${err}`); - } + const columns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables/${tableId}/columns`, {}); for (const column of columns) { const columnName = column.name; const columnId = column.id; @@ -166,13 +151,8 @@ export class Coda implements INodeType { // select them easily async getViews(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - let views; const docId = this.getCurrentNodeParameter('docId'); - try { - views = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views`, {}); - } catch (err) { - throw new Error(`Coda Error: ${err}`); - } + const views = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views`, {}); for (const view of views) { const viewName = view.name; const viewId = view.id; @@ -187,13 +167,8 @@ export class Coda implements INodeType { // select them easily async getFormulas(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - let formulas; const docId = this.getCurrentNodeParameter('docId'); - try { - formulas = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/formulas`, {}); - } catch (err) { - throw new Error(`Coda Error: ${err}`); - } + const formulas = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/formulas`, {}); for (const formula of formulas) { const formulaName = formula.name; const formulaId = formula.id; @@ -208,14 +183,9 @@ export class Coda implements INodeType { // select them easily async getViewRows(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - let viewRows; const docId = this.getCurrentNodeParameter('docId'); const viewId = this.getCurrentNodeParameter('viewId'); - try { - viewRows = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views/${viewId}/rows`, {}); - } catch (err) { - throw new Error(`Coda Error: ${err}`); - } + const viewRows = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views/${viewId}/rows`, {}); for (const viewRow of viewRows) { const viewRowName = viewRow.name; const viewRowId = viewRow.id; @@ -230,16 +200,11 @@ export class Coda implements INodeType { // select them easily async getViewColumns(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - let viewColumns; const docId = this.getCurrentNodeParameter('docId'); const viewId = this.getCurrentNodeParameter('viewId'); - try { - viewColumns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views/${viewId}/columns`, {}); - } catch (err) { - throw new Error(`Coda Error: ${err}`); - } + const viewColumns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/views/${viewId}/columns`, {}); for (const viewColumn of viewColumns) { const viewColumnName = viewColumn.name; const viewColumnId = viewColumn.id; @@ -422,7 +387,7 @@ export class Coda implements INodeType { const columnId = this.getNodeParameter('columnId', i) as string; const endpoint = `/docs/${docId}/tables/${tableId}/rows/${rowId}/buttons/${columnId}`; responseData = await codaApiRequest.call(this, 'POST', endpoint, {}); - returnData.push(responseData) + returnData.push(responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -434,7 +399,7 @@ export class Coda implements INodeType { const columnId = this.getNodeParameter('columnId', i) as string; const endpoint = `/docs/${docId}/tables/${tableId}/columns/${columnId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); - returnData.push(responseData) + returnData.push(responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -452,7 +417,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData) + returnData.push.apply(returnData,responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -465,7 +430,7 @@ export class Coda implements INodeType { const formulaId = this.getNodeParameter('formulaId', i) as string; const endpoint = `/docs/${docId}/formulas/${formulaId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); - returnData.push(responseData) + returnData.push(responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -482,7 +447,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData) + returnData.push.apply(returnData,responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -495,7 +460,7 @@ export class Coda implements INodeType { const controlId = this.getNodeParameter('controlId', i) as string; const endpoint = `/docs/${docId}/controls/${controlId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); - returnData.push(responseData) + returnData.push(responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -512,7 +477,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData) + returnData.push.apply(returnData,responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -525,7 +490,7 @@ export class Coda implements INodeType { const viewId = this.getNodeParameter('viewId', i) as string; const endpoint = `/docs/${docId}/views/${viewId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); - returnData.push(responseData) + returnData.push(responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -542,7 +507,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData) + returnData.push.apply(returnData,responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -584,7 +549,7 @@ export class Coda implements INodeType { for (const item of responseData) { returnData.push({ id: item.id, - ...item.values + ...item.values, }); } return [this.helpers.returnJsonArray(returnData)]; @@ -598,7 +563,7 @@ export class Coda implements INodeType { const rowId = this.getNodeParameter('rowId', i) as string; const endpoint = `/docs/${docId}/views/${viewId}/rows/${rowId}`; responseData = await codaApiRequest.call(this, 'DELETE', endpoint); - returnData.push.apply(returnData,responseData) + returnData.push.apply(returnData,responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -611,7 +576,7 @@ export class Coda implements INodeType { const columnId = this.getNodeParameter('columnId', i) as string; const endpoint = `/docs/${docId}/views/${viewId}/rows/${rowId}/buttons/${columnId}`; responseData = await codaApiRequest.call(this, 'POST', endpoint); - returnData.push.apply(returnData,responseData) + returnData.push.apply(returnData,responseData); } return [this.helpers.returnJsonArray(returnData)]; } @@ -628,7 +593,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData) + returnData.push.apply(returnData,responseData); } return [this.helpers.returnJsonArray(returnData)]; } diff --git a/packages/nodes-base/nodes/Coda/GenericFunctions.ts b/packages/nodes-base/nodes/Coda/GenericFunctions.ts index 2d26d593a7..5752a81314 100644 --- a/packages/nodes-base/nodes/Coda/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Coda/GenericFunctions.ts @@ -32,7 +32,7 @@ export async function codaApiRequest(this: IExecuteFunctions | IExecuteSingleFun errorMessage = error.response.body.message || error.response.body.Message || error.message; } - throw new Error(errorMessage); + throw new Error('Coda Error: ' + errorMessage); } } diff --git a/packages/nodes-base/nodes/Coda/TableDescription.ts b/packages/nodes-base/nodes/Coda/TableDescription.ts index 1b601ccf30..4eb40bbe6a 100644 --- a/packages/nodes-base/nodes/Coda/TableDescription.ts +++ b/packages/nodes-base/nodes/Coda/TableDescription.ts @@ -19,34 +19,34 @@ export const tableOperations = [ description: 'Create/Upsert a row', }, { - name: 'Get Row', - value: 'getRow', - description: 'Get row', + name: 'Delete Row', + value: 'deleteRow', + description: 'Delete one or multiple rows', + }, + { + name: 'Get All Columns', + value: 'getAllColumns', + description: 'Get all columns', }, { name: 'Get All Rows', value: 'getAllRows', description: 'Get all the rows', }, - { - name: 'Delete Row', - value: 'deleteRow', - description: 'Delete one or multiple rows', - }, - { - name: 'Push Button', - value: 'pushButton', - description: 'Pushes a button', - }, { name: 'Get Column', value: 'getColumn', description: 'Get a column', }, { - name: 'Get All Columns', - value: 'getAllColumns', - description: 'Get all columns', + name: 'Get Row', + value: 'getRow', + description: 'Get row', + }, + { + name: 'Push Button', + value: 'pushButton', + description: 'Pushes a button', }, ], default: 'createRow', @@ -121,14 +121,6 @@ export const tableFields = [ }, }, options: [ - { - displayName: 'Key Columns', - name: 'keyColumns', - type: 'string', - default: '', - description: `Optional column IDs, URLs, or names (fragile and discouraged), - specifying columns to be used as upsert keys. If more than one separate by ,`, - }, { displayName: 'Disable Parsing', name: 'disableParsing', @@ -136,6 +128,14 @@ export const tableFields = [ default: false, description: `If true, the API will not attempt to parse the data in any way.`, }, + { + displayName: 'Key Columns', + name: 'keyColumns', + type: 'string', + default: '', + description: `Optional column IDs, URLs, or names (fragile and discouraged)
, + specifying columns to be used as upsert keys. If more than one separate by ,`, + }, ] }, /* -------------------------------------------------------------------------- */ @@ -202,9 +202,11 @@ export const tableFields = [ ] }, }, - description: `ID or name of the row. Names are discouraged because they're easily prone to being changed by users. - If you're using a name, be sure to URI-encode it. - If there are multiple rows with the same value in the identifying column, an arbitrary one will be selected`, + description: `ID or name of the row. Names are discouraged because
+ they're easily prone to being changed by users. If you're
+ using a name, be sure to URI-encode it. If there are
+ multiple rows with the same value in the identifying column,
+ an arbitrary one will be selected`, }, { displayName: 'Options', @@ -223,6 +225,13 @@ export const tableFields = [ }, }, options: [ + { + displayName: 'RAW Data', + name: 'rawData', + type: 'boolean', + default: false, + description: `Returns the data exactly in the way it got received from the API.`, + }, { displayName: 'Use Column Names', name: 'useColumnNames', @@ -232,13 +241,6 @@ export const tableFields = [ This is generally discouraged as it is fragile. If columns are renamed,
code using original names may throw errors.`, }, - { - displayName: 'RAW Data', - name: 'rawData', - type: 'boolean', - default: false, - description: `Returns the data exactly in the way it got received from the API.`, - }, { displayName: 'ValueFormat', name: 'valueFormat', @@ -380,36 +382,6 @@ export const tableFields = [ If you'd like to use a column name instead of an ID, you must quote it (e.g., "My Column":123).
Also note that value is a JSON value; if you'd like to use a string, you must surround it in quotes (e.g., "groceries").`, }, - { - displayName: 'Use Column Names', - name: 'useColumnNames', - type: 'boolean', - default: false, - description: `Use column names instead of column IDs in the returned output.
- This is generally discouraged as it is fragile. If columns are renamed,
- code using original names may throw errors.`, - }, - { - displayName: 'ValueFormat', - name: 'valueFormat', - type: 'options', - default: '', - options: [ - { - name: 'Simple', - value: 'simple', - }, - { - name: 'Simple With Arrays', - value: 'simpleWithArrays', - }, - { - name: 'Rich', - value: 'rich', - }, - ], - description: `The format that cell values are returned as.`, - }, { displayName: 'RAW Data', name: 'rawData', @@ -432,9 +404,39 @@ export const tableFields = [ value: 'natural', }, ], - description: `Specifies the sort order of the rows returned. + description: `Specifies the sort order of the rows returned.
If left unspecified, rows are returned by creation time ascending.`, }, + { + displayName: 'Use Column Names', + name: 'useColumnNames', + type: 'boolean', + default: false, + description: `Use column names instead of column IDs in the returned output.
+ This is generally discouraged as it is fragile. If columns
+ are renamed, code using original names may throw errors.`, + }, + { + displayName: 'ValueFormat', + name: 'valueFormat', + type: 'options', + default: '', + options: [ + { + name: 'Simple', + value: 'simple', + }, + { + name: 'Simple With Arrays', + value: 'simpleWithArrays', + }, + { + name: 'Rich', + value: 'rich', + }, + ], + description: `The format that cell values are returned as.`, + }, { displayName: 'Visible Only', name: 'visibleOnly', @@ -574,9 +576,11 @@ export const tableFields = [ ] }, }, - description: `ID or name of the row. Names are discouraged because they're easily prone to being changed by users. - If you're using a name, be sure to URI-encode it. - If there are multiple rows with the same value in the identifying column, an arbitrary one will be selected`, + description: `ID or name of the row. Names are discouraged because
+ they're easily prone to being changed by users. If you're
+ using a name, be sure to URI-encode it. If there are multiple
+ rows with the same value in the identifying column, an arbitrary
+ one will be selected`, }, { displayName: 'Column', diff --git a/packages/nodes-base/nodes/Coda/ViewDescription.ts b/packages/nodes-base/nodes/Coda/ViewDescription.ts index a462e3848c..d9c8472609 100644 --- a/packages/nodes-base/nodes/Coda/ViewDescription.ts +++ b/packages/nodes-base/nodes/Coda/ViewDescription.ts @@ -13,6 +13,11 @@ export const viewOperations = [ }, }, options: [ + { + name: 'Delete Row', + value: 'deleteViewRow', + description: 'Delete view row', + }, { name: 'Get', value: 'get', @@ -23,26 +28,21 @@ export const viewOperations = [ value: 'getAll', description: 'Get all views', }, - { - name: 'Get Rows', - value: 'getAllViewRows', - description: 'Get all views rows', - }, { name: 'Get Columns', value: 'getAllViewColumns', description: 'Get all views columns', }, + { + name: 'Get Rows', + value: 'getAllViewRows', + description: 'Get all views rows', + }, { name: 'Update Row', value: 'updateViewRow', description: 'Update row', }, - { - name: 'Delete Row', - value: 'deleteViewRow', - description: 'Delete view row', - }, { name: 'Push Button', value: 'pushViewButton', @@ -333,7 +333,7 @@ export const viewFields = [ value: 'natural', }, ], - description: `Specifies the sort order of the rows returned. + description: `Specifies the sort order of the rows returned.
If left unspecified, rows are returned by creation time ascending.`, }, ]