mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Add Quick Base Node (#1161)
* introduce quick base node * fix quick base api request headers * refine quick base configuration pages * fix race condition detection * ⚡ improvements Co-authored-by: Tristian Flanagan <tristian@tristianflanagan.com>
This commit is contained in:
25
packages/nodes-base/credentials/QuickBaseApi.credentials.ts
Normal file
25
packages/nodes-base/credentials/QuickBaseApi.credentials.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import {
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export class QuickBaseApi implements ICredentialType {
|
||||||
|
name = 'quickbaseApi';
|
||||||
|
displayName = 'Quick Base API';
|
||||||
|
documentationUrl = 'quickbase';
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
displayName: 'Hostname',
|
||||||
|
name: 'hostname',
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
placeholder: 'demo.quickbase.com',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'User Token',
|
||||||
|
name: 'userToken',
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
118
packages/nodes-base/nodes/QuickBase/FieldDescription.ts
Normal file
118
packages/nodes-base/nodes/QuickBase/FieldDescription.ts
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
import {
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export const fieldOperations = [
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'field',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Get All',
|
||||||
|
value: 'getAll',
|
||||||
|
description: 'Get all fields',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'create',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
export const fieldFields = [
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* field:getAll */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'field',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'field',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'Returns a list of your user contacts.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'field',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 100,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Options',
|
||||||
|
name: 'options',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'field',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Include Field Perms',
|
||||||
|
name: 'includeFieldPerms',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: `Set to 'true' if you'd like to get back the custom permissions for the field(s)`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
132
packages/nodes-base/nodes/QuickBase/FileDescription.ts
Normal file
132
packages/nodes-base/nodes/QuickBase/FileDescription.ts
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
import {
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export const fileOperations = [
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Delete',
|
||||||
|
value: 'delete',
|
||||||
|
description: 'Delete a file',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Download',
|
||||||
|
value: 'download',
|
||||||
|
description: 'Download a file',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'download',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
export const fileFields = [
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* file:download */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'download',
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Record ID',
|
||||||
|
name: 'recordId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'download',
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The unique identifier of the record',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Field ID',
|
||||||
|
name: 'fieldId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'download',
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The unique identifier of the field.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Version Number',
|
||||||
|
name: 'versionNumber',
|
||||||
|
type: 'number',
|
||||||
|
default: 1,
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'download',
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The file attachment version number.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Binary Property',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'file',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'download',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
name: 'binaryPropertyName',
|
||||||
|
type: 'string',
|
||||||
|
default: 'data',
|
||||||
|
description: 'Object property name which holds binary data.',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
132
packages/nodes-base/nodes/QuickBase/GenericFunctions.ts
Normal file
132
packages/nodes-base/nodes/QuickBase/GenericFunctions.ts
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
import {
|
||||||
|
OptionsWithUri,
|
||||||
|
} from 'request';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IExecuteFunctions,
|
||||||
|
IHookFunctions,
|
||||||
|
ILoadOptionsFunctions,
|
||||||
|
IWebhookFunctions,
|
||||||
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IDataObject,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export async function quickbaseApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
|
const credentials = this.getCredentials('quickbaseApi') as IDataObject;
|
||||||
|
|
||||||
|
if (credentials.hostname === '') {
|
||||||
|
throw new Error('Hostname must be defined');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (credentials.userKey === '') {
|
||||||
|
throw new Error('User Token must be defined');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options: OptionsWithUri = {
|
||||||
|
headers: {
|
||||||
|
'QB-Realm-Hostname': credentials.hostname,
|
||||||
|
'User-Agent': 'n8n',
|
||||||
|
'Authorization': `QB-USER-TOKEN ${credentials.userToken}`,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
method,
|
||||||
|
body,
|
||||||
|
qs,
|
||||||
|
uri: `https://api.quickbase.com/v1${resource}`,
|
||||||
|
json: true,
|
||||||
|
};
|
||||||
|
if (Object.keys(body).length === 0) {
|
||||||
|
delete options.body;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(qs).length === 0) {
|
||||||
|
delete options.qs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(option).length !== 0) {
|
||||||
|
Object.assign(options, option);
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
return await this.helpers?.request(options);
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
if (error.response && error.response.body && error.response.body.description) {
|
||||||
|
|
||||||
|
const message = error.response.body.description;
|
||||||
|
|
||||||
|
// Try to return the error prettier
|
||||||
|
throw new Error(
|
||||||
|
`Quickbase error response [${error.statusCode}]: ${message} (qb-api-ray=${error.response.headers['qb-api-ray']})`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@ts-ignore
|
||||||
|
export async function getFieldsObject(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, tableId: string): any {
|
||||||
|
const fieldsLabelKey: { [key: string]: number } = {};
|
||||||
|
const fieldsIdKey: { [key: number]: string } = {};
|
||||||
|
const data = await quickbaseApiRequest.call(this, 'GET', '/fields', {}, { tableId });
|
||||||
|
for (const field of data) {
|
||||||
|
fieldsLabelKey[field.label] = field.id;
|
||||||
|
fieldsIdKey[field.id] = field.label;
|
||||||
|
}
|
||||||
|
return { fieldsLabelKey, fieldsIdKey };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function quickbaseApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
|
||||||
|
const returnData: IDataObject[] = [];
|
||||||
|
|
||||||
|
let responseData = [];
|
||||||
|
|
||||||
|
if (method === 'POST') {
|
||||||
|
body.options = {
|
||||||
|
skip: 0,
|
||||||
|
top: 100,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
query.skip = 0;
|
||||||
|
query.top = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
let metadata;
|
||||||
|
|
||||||
|
do {
|
||||||
|
const { data, fields, metadata: meta } = await quickbaseApiRequest.call(this, method, resource, body, query);
|
||||||
|
|
||||||
|
metadata = meta;
|
||||||
|
|
||||||
|
const fieldsIdKey: { [key: string]: string } = {};
|
||||||
|
|
||||||
|
for (const field of fields) {
|
||||||
|
fieldsIdKey[field.id] = field.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const record of data) {
|
||||||
|
const data: IDataObject = {};
|
||||||
|
for (const [key, value] of Object.entries(record)) {
|
||||||
|
data[fieldsIdKey[key]] = (value as IDataObject).value;
|
||||||
|
}
|
||||||
|
responseData.push(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method === 'POST') {
|
||||||
|
body.options.skip += body.options.top;
|
||||||
|
} else {
|
||||||
|
//@ts-ignore
|
||||||
|
query.skip += query.top;
|
||||||
|
}
|
||||||
|
returnData.push.apply(returnData, responseData);
|
||||||
|
responseData = [];
|
||||||
|
} while (
|
||||||
|
returnData.length < metadata.totalRecords
|
||||||
|
);
|
||||||
|
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
561
packages/nodes-base/nodes/QuickBase/QuickBase.node.ts
Normal file
561
packages/nodes-base/nodes/QuickBase/QuickBase.node.ts
Normal file
@@ -0,0 +1,561 @@
|
|||||||
|
import {
|
||||||
|
IExecuteFunctions,
|
||||||
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IDataObject,
|
||||||
|
ILoadOptionsFunctions,
|
||||||
|
INodeExecutionData,
|
||||||
|
INodePropertyOptions,
|
||||||
|
INodeType,
|
||||||
|
INodeTypeDescription,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getFieldsObject,
|
||||||
|
quickbaseApiRequest,
|
||||||
|
quickbaseApiRequestAllItems,
|
||||||
|
} from './GenericFunctions';
|
||||||
|
|
||||||
|
import {
|
||||||
|
fieldFields,
|
||||||
|
fieldOperations,
|
||||||
|
} from './FieldDescription';
|
||||||
|
|
||||||
|
import {
|
||||||
|
fileFields,
|
||||||
|
fileOperations,
|
||||||
|
} from './FileDescription';
|
||||||
|
|
||||||
|
import {
|
||||||
|
recordFields,
|
||||||
|
recordOperations,
|
||||||
|
} from './RecordDescription';
|
||||||
|
|
||||||
|
import {
|
||||||
|
reportFields,
|
||||||
|
reportOperations,
|
||||||
|
} from './ReportDescription';
|
||||||
|
|
||||||
|
export class QuickBase implements INodeType {
|
||||||
|
description: INodeTypeDescription = {
|
||||||
|
displayName: 'Quick Base',
|
||||||
|
name: 'quickbase',
|
||||||
|
icon: 'file:quickbase.png',
|
||||||
|
group: [ 'input' ],
|
||||||
|
version: 1,
|
||||||
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||||
|
description: 'Integrate with the Quick Base RESTful API.',
|
||||||
|
defaults: {
|
||||||
|
name: 'Quick Base',
|
||||||
|
color: '#73489d',
|
||||||
|
},
|
||||||
|
inputs: [ 'main' ],
|
||||||
|
outputs: [ 'main' ],
|
||||||
|
credentials: [
|
||||||
|
{
|
||||||
|
name: 'quickbaseApi',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
|
displayName: 'Resource',
|
||||||
|
name: 'resource',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Field',
|
||||||
|
value: 'field',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'File',
|
||||||
|
value: 'file',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Record',
|
||||||
|
value: 'record',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Report',
|
||||||
|
value: 'report',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'record',
|
||||||
|
description: 'The resource to operate on.',
|
||||||
|
},
|
||||||
|
...fieldOperations,
|
||||||
|
...fieldFields,
|
||||||
|
...fileOperations,
|
||||||
|
...fileFields,
|
||||||
|
...recordOperations,
|
||||||
|
...recordFields,
|
||||||
|
...reportOperations,
|
||||||
|
...reportFields,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
methods = {
|
||||||
|
loadOptions: {
|
||||||
|
async getTableFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
const tableId = this.getCurrentNodeParameter('tableId') as string;
|
||||||
|
const fields = await quickbaseApiRequest.call(this, 'GET', '/fields', {}, { tableId });
|
||||||
|
for (const field of fields) {
|
||||||
|
returnData.push({
|
||||||
|
name: field.label,
|
||||||
|
value: field.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
async getUniqueTableFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
const tableId = this.getCurrentNodeParameter('tableId') as string;
|
||||||
|
const fields = await quickbaseApiRequest.call(this, 'GET', '/fields', {}, { tableId });
|
||||||
|
for (const field of fields) {
|
||||||
|
//upsert can be achived just with fields that are set as unique and are no the primary key
|
||||||
|
if (field.unique === true && field.properties.primaryKey === false) {
|
||||||
|
returnData.push({
|
||||||
|
name: field.label,
|
||||||
|
value: field.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
|
const items = this.getInputData();
|
||||||
|
const returnData: IDataObject[] = [];
|
||||||
|
const length = (items.length as unknown) as number;
|
||||||
|
const qs: IDataObject = {};
|
||||||
|
const headers: IDataObject = {};
|
||||||
|
let responseData;
|
||||||
|
const resource = this.getNodeParameter('resource', 0) as string;
|
||||||
|
const operation = this.getNodeParameter('operation', 0) as string;
|
||||||
|
|
||||||
|
if (resource === 'field') {
|
||||||
|
if (operation === 'getAll') {
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
|
|
||||||
|
const tableId = this.getNodeParameter('tableId', i) as string;
|
||||||
|
|
||||||
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
|
|
||||||
|
const qs: IDataObject = {
|
||||||
|
tableId,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.assign(qs, options);
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'GET', '/fields', {}, qs);
|
||||||
|
|
||||||
|
if (returnAll === false) {
|
||||||
|
const limit = this.getNodeParameter('limit', i) as number;
|
||||||
|
|
||||||
|
responseData = responseData.splice(0, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
returnData.push.apply(returnData, responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resource === 'file') {
|
||||||
|
if (operation === 'delete') {
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
const tableId = this.getNodeParameter('tableId', i) as string;
|
||||||
|
|
||||||
|
const recordId = this.getNodeParameter('recordId', i) as string;
|
||||||
|
|
||||||
|
const fieldId = this.getNodeParameter('fieldId', i) as string;
|
||||||
|
|
||||||
|
const versionNumber = this.getNodeParameter('versionNumber', i) as string;
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this,'DELETE', `/files/${tableId}/${recordId}/${fieldId}/${versionNumber}`);
|
||||||
|
|
||||||
|
returnData.push(responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation === 'download') {
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
|
||||||
|
const tableId = this.getNodeParameter('tableId', i) as string;
|
||||||
|
|
||||||
|
const recordId = this.getNodeParameter('recordId', i) as string;
|
||||||
|
|
||||||
|
const fieldId = this.getNodeParameter('fieldId', i) as string;
|
||||||
|
|
||||||
|
const versionNumber = this.getNodeParameter('versionNumber', i) as string;
|
||||||
|
|
||||||
|
const newItem: INodeExecutionData = {
|
||||||
|
json: items[i].json,
|
||||||
|
binary: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
if (items[i].binary !== undefined) {
|
||||||
|
// Create a shallow copy of the binary data so that the old
|
||||||
|
// data references which do not get changed still stay behind
|
||||||
|
// but the incoming data does not get changed.
|
||||||
|
Object.assign(newItem.binary, items[i].binary);
|
||||||
|
}
|
||||||
|
|
||||||
|
items[i] = newItem;
|
||||||
|
|
||||||
|
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this,'GET', `/files/${tableId}/${recordId}/${fieldId}/${versionNumber}`, {}, {}, { json: false, resolveWithFullResponse: true });
|
||||||
|
|
||||||
|
//content-disposition': 'attachment; filename="dog-puppy-on-garden-royalty-free-image-1586966191.jpg"',
|
||||||
|
const contentDisposition = responseData.headers['content-disposition'];
|
||||||
|
|
||||||
|
const data = Buffer.from(responseData.body as string, 'base64');
|
||||||
|
|
||||||
|
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, contentDisposition.split('=')[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.prepareOutputData(items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resource === 'record') {
|
||||||
|
if (operation === 'create') {
|
||||||
|
const tableId = this.getNodeParameter('tableId', 0) as string;
|
||||||
|
|
||||||
|
const { fieldsLabelKey, fieldsIdKey } = await getFieldsObject.call(this, tableId);
|
||||||
|
|
||||||
|
const simple = this.getNodeParameter('simple', 0) as boolean;
|
||||||
|
|
||||||
|
const data: IDataObject[] = [];
|
||||||
|
|
||||||
|
const options = this.getNodeParameter('options', 0) as IDataObject;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
const record: IDataObject = {};
|
||||||
|
|
||||||
|
const columns = this.getNodeParameter('columns', i) as string;
|
||||||
|
|
||||||
|
const columnList = columns.split(',').map(column => column.trim());
|
||||||
|
|
||||||
|
for (const key of Object.keys(items[i].json)) {
|
||||||
|
if (fieldsLabelKey.hasOwnProperty(key) && columnList.includes(key)) {
|
||||||
|
record[fieldsLabelKey[key].toString()] = { value: items[i].json[key] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.push(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
const body: IDataObject = {
|
||||||
|
data,
|
||||||
|
to: tableId,
|
||||||
|
};
|
||||||
|
|
||||||
|
// If not fields are set return at least the record id
|
||||||
|
body.fieldsToReturn = [fieldsLabelKey['Record ID#']];
|
||||||
|
|
||||||
|
if (options.fields) {
|
||||||
|
body.fieldsToReturn = options.fields as string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'POST', '/records', body);
|
||||||
|
|
||||||
|
if (simple === true) {
|
||||||
|
const { data: records } = responseData;
|
||||||
|
responseData = [];
|
||||||
|
|
||||||
|
for (const record of records) {
|
||||||
|
const data: IDataObject = {};
|
||||||
|
for (const [key, value] of Object.entries(record)) {
|
||||||
|
data[fieldsIdKey[key]] = (value as IDataObject).value;
|
||||||
|
}
|
||||||
|
responseData.push(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(responseData)) {
|
||||||
|
returnData.push.apply(returnData, responseData);
|
||||||
|
} else {
|
||||||
|
returnData.push(responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation === 'delete') {
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
const tableId = this.getNodeParameter('tableId', i) as string;
|
||||||
|
|
||||||
|
const where = this.getNodeParameter('where', i) as string;
|
||||||
|
|
||||||
|
const body: IDataObject = {
|
||||||
|
from: tableId,
|
||||||
|
where,
|
||||||
|
};
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'DELETE', '/records', body);
|
||||||
|
|
||||||
|
returnData.push(responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation === 'getAll') {
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
|
|
||||||
|
const tableId = this.getNodeParameter('tableId', i) as string;
|
||||||
|
|
||||||
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
|
|
||||||
|
const body: IDataObject = {
|
||||||
|
from: tableId,
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.assign(body, options);
|
||||||
|
|
||||||
|
if (options.sortByUi) {
|
||||||
|
const sort = (options.sortByUi as IDataObject).sortByValues as IDataObject[];
|
||||||
|
body.sortBy = sort;
|
||||||
|
delete body.sortByUi;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (options.groupByUi) {
|
||||||
|
// const group = (options.groupByUi as IDataObject).groupByValues as IDataObject[];
|
||||||
|
// body.groupBy = group;
|
||||||
|
// delete body.groupByUi;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (returnAll) {
|
||||||
|
responseData = await quickbaseApiRequestAllItems.call(this, 'POST', '/records/query', body, qs);
|
||||||
|
} else {
|
||||||
|
body.options = { top: this.getNodeParameter('limit', i) as number };
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'POST', '/records/query', body, qs);
|
||||||
|
|
||||||
|
const { data: records, fields } = responseData;
|
||||||
|
responseData = [];
|
||||||
|
|
||||||
|
const fieldsIdKey: { [key: string]: string } = {};
|
||||||
|
|
||||||
|
for (const field of fields) {
|
||||||
|
fieldsIdKey[field.id] = field.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const record of records) {
|
||||||
|
const data: IDataObject = {};
|
||||||
|
for (const [key, value] of Object.entries(record)) {
|
||||||
|
data[fieldsIdKey[key]] = (value as IDataObject).value;
|
||||||
|
}
|
||||||
|
responseData.push(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
returnData.push.apply(returnData, responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation === 'update') {
|
||||||
|
const tableId = this.getNodeParameter('tableId', 0) as string;
|
||||||
|
|
||||||
|
const { fieldsLabelKey, fieldsIdKey } = await getFieldsObject.call(this, tableId);
|
||||||
|
|
||||||
|
const simple = this.getNodeParameter('simple', 0) as boolean;
|
||||||
|
|
||||||
|
const updateKey = this.getNodeParameter('updateKey', 0) as string;
|
||||||
|
|
||||||
|
const data: IDataObject[] = [];
|
||||||
|
|
||||||
|
const options = this.getNodeParameter('options', 0) as IDataObject;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
const record: IDataObject = {};
|
||||||
|
|
||||||
|
const columns = this.getNodeParameter('columns', i) as string;
|
||||||
|
|
||||||
|
const columnList = columns.split(',').map(column => column.trim());
|
||||||
|
|
||||||
|
for (const key of Object.keys(items[i].json)) {
|
||||||
|
if (fieldsLabelKey.hasOwnProperty(key) && columnList.includes(key)) {
|
||||||
|
record[fieldsLabelKey[key].toString()] = { value: items[i].json[key] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (items[i].json[updateKey] === undefined) {
|
||||||
|
throw new Error(`The update key ${updateKey} could not be found in the input`);
|
||||||
|
}
|
||||||
|
|
||||||
|
record[fieldsLabelKey['Record ID#']] = { value: items[i].json[updateKey] };
|
||||||
|
|
||||||
|
data.push(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
const body: IDataObject = {
|
||||||
|
data,
|
||||||
|
to: tableId,
|
||||||
|
};
|
||||||
|
|
||||||
|
// If not fields are set return at least the record id
|
||||||
|
body.fieldsToReturn = [fieldsLabelKey['Record ID#']];
|
||||||
|
|
||||||
|
if (options.fields) {
|
||||||
|
body.fieldsToReturn = options.fields as string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'POST', '/records', body);
|
||||||
|
|
||||||
|
if (simple === true) {
|
||||||
|
const { data: records } = responseData;
|
||||||
|
responseData = [];
|
||||||
|
|
||||||
|
for (const record of records) {
|
||||||
|
const data: IDataObject = {};
|
||||||
|
for (const [key, value] of Object.entries(record)) {
|
||||||
|
data[fieldsIdKey[key]] = (value as IDataObject).value;
|
||||||
|
}
|
||||||
|
responseData.push(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(responseData)) {
|
||||||
|
returnData.push.apply(returnData, responseData);
|
||||||
|
} else {
|
||||||
|
returnData.push(responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation === 'upsert') {
|
||||||
|
const tableId = this.getNodeParameter('tableId', 0) as string;
|
||||||
|
|
||||||
|
const { fieldsLabelKey, fieldsIdKey } = await getFieldsObject.call(this, tableId);
|
||||||
|
|
||||||
|
const simple = this.getNodeParameter('simple', 0) as boolean;
|
||||||
|
|
||||||
|
const updateKey = this.getNodeParameter('updateKey', 0) as string;
|
||||||
|
|
||||||
|
const mergeFieldId = this.getNodeParameter('mergeFieldId', 0) as string;
|
||||||
|
|
||||||
|
const data: IDataObject[] = [];
|
||||||
|
|
||||||
|
const options = this.getNodeParameter('options', 0) as IDataObject;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
const record: IDataObject = {};
|
||||||
|
|
||||||
|
const columns = this.getNodeParameter('columns', i) as string;
|
||||||
|
|
||||||
|
const columnList = columns.split(',').map(column => column.trim());
|
||||||
|
|
||||||
|
for (const key of Object.keys(items[i].json)) {
|
||||||
|
if (fieldsLabelKey.hasOwnProperty(key) && columnList.includes(key)) {
|
||||||
|
record[fieldsLabelKey[key].toString()] = { value: items[i].json[key] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (items[i].json[updateKey] === undefined) {
|
||||||
|
throw new Error(`The update key ${updateKey} could not be found in the input`);
|
||||||
|
}
|
||||||
|
|
||||||
|
record[mergeFieldId] = { value: items[i].json[updateKey] };
|
||||||
|
|
||||||
|
data.push(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
const body: IDataObject = {
|
||||||
|
data,
|
||||||
|
to: tableId,
|
||||||
|
mergeFieldId,
|
||||||
|
};
|
||||||
|
|
||||||
|
// If not fields are set return at least the record id
|
||||||
|
body.fieldsToReturn = [fieldsLabelKey['Record ID#']];
|
||||||
|
|
||||||
|
if (options.fields) {
|
||||||
|
body.fieldsToReturn = options.fields as string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'POST', '/records', body);
|
||||||
|
|
||||||
|
if (simple === true) {
|
||||||
|
const { data: records } = responseData;
|
||||||
|
responseData = [];
|
||||||
|
|
||||||
|
for (const record of records) {
|
||||||
|
const data: IDataObject = {};
|
||||||
|
for (const [key, value] of Object.entries(record)) {
|
||||||
|
data[fieldsIdKey[key]] = (value as IDataObject).value;
|
||||||
|
}
|
||||||
|
responseData.push(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(responseData)) {
|
||||||
|
returnData.push.apply(returnData, responseData);
|
||||||
|
} else {
|
||||||
|
returnData.push(responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resource === 'report') {
|
||||||
|
|
||||||
|
if (operation === 'run') {
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
|
||||||
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
|
|
||||||
|
const tableId = this.getNodeParameter('tableId', i) as string;
|
||||||
|
|
||||||
|
const reportId = this.getNodeParameter('reportId', i) as string;
|
||||||
|
|
||||||
|
qs.tableId = tableId;
|
||||||
|
|
||||||
|
if (returnAll) {
|
||||||
|
responseData = await quickbaseApiRequestAllItems.call(this, 'POST', `/reports/${reportId}/run`, {}, qs);
|
||||||
|
} else {
|
||||||
|
qs.top = this.getNodeParameter('limit', i) as number;
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'POST', `/reports/${reportId}/run`, {}, qs);
|
||||||
|
|
||||||
|
const { data: records, fields } = responseData;
|
||||||
|
responseData = [];
|
||||||
|
|
||||||
|
const fieldsIdKey: { [key: string]: string } = {};
|
||||||
|
|
||||||
|
for (const field of fields) {
|
||||||
|
fieldsIdKey[field.id] = field.label;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const record of records) {
|
||||||
|
const data: IDataObject = {};
|
||||||
|
for (const [key, value] of Object.entries(record)) {
|
||||||
|
data[fieldsIdKey[key]] = (value as IDataObject).value;
|
||||||
|
}
|
||||||
|
responseData.push(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
returnData.push.apply(returnData, responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operation === 'get') {
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
|
||||||
|
const reportId = this.getNodeParameter('reportId', i) as string;
|
||||||
|
|
||||||
|
const tableId = this.getNodeParameter('tableId', i) as string;
|
||||||
|
|
||||||
|
qs.tableId = tableId;
|
||||||
|
|
||||||
|
responseData = await quickbaseApiRequest.call(this, 'GET', `/reports/${reportId}`, {}, qs);
|
||||||
|
|
||||||
|
returnData.push(responseData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
|
}
|
||||||
|
}
|
||||||
614
packages/nodes-base/nodes/QuickBase/RecordDescription.ts
Normal file
614
packages/nodes-base/nodes/QuickBase/RecordDescription.ts
Normal file
@@ -0,0 +1,614 @@
|
|||||||
|
import {
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export const recordOperations = [
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Create',
|
||||||
|
value: 'create',
|
||||||
|
description: 'Create a record',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Delete',
|
||||||
|
value: 'delete',
|
||||||
|
description: 'Delete a record',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Get All',
|
||||||
|
value: 'getAll',
|
||||||
|
description: 'Get all records',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Update',
|
||||||
|
value: 'update',
|
||||||
|
description: 'Update a record',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Upsert',
|
||||||
|
value: 'upsert',
|
||||||
|
description: 'Upsert a record',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'create',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
export const recordFields = [
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* record:create */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Columns',
|
||||||
|
name: 'columns',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
placeholder: 'id,name,description',
|
||||||
|
description: 'Comma separated list of the properties which should used as columns for the new rows.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Simple',
|
||||||
|
name: 'simple',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: true,
|
||||||
|
description: 'When set to true a simplify version of the response will be used else the raw data.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Options',
|
||||||
|
name: 'options',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Option',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Fields',
|
||||||
|
name: 'fields',
|
||||||
|
type: 'multiOptions',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getTableFields',
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'tableId',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
description: `Specify an array of field ids that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested.`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* record:delete */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Where',
|
||||||
|
name: 'where',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'delete',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: `The filter to delete records. To delete all records specify a filter that will include all records,</br>
|
||||||
|
for example {3.GT.0} where 3 is the ID of the Record ID field.`,
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* record:getAll */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: false,
|
||||||
|
description: 'Returns a list of your user contacts.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
returnAll: [
|
||||||
|
false,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 100,
|
||||||
|
},
|
||||||
|
default: 50,
|
||||||
|
description: 'How many results to return.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Options',
|
||||||
|
name: 'options',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'getAll',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
// {
|
||||||
|
// displayName: 'Group By',
|
||||||
|
// name: 'groupByUi',
|
||||||
|
// placeholder: 'Add Group By',
|
||||||
|
// type: 'fixedCollection',
|
||||||
|
// typeOptions: {
|
||||||
|
// multipleValues: true,
|
||||||
|
// },
|
||||||
|
// default: {},
|
||||||
|
// options: [
|
||||||
|
// {
|
||||||
|
// name: 'groupByValues',
|
||||||
|
// displayName: 'Group By',
|
||||||
|
// values: [
|
||||||
|
// {
|
||||||
|
// displayName: 'Field ID',
|
||||||
|
// name: 'fieldId',
|
||||||
|
// type: 'options',
|
||||||
|
// typeOptions: {
|
||||||
|
// loadOptionsMethod: 'getTableFields',
|
||||||
|
// },
|
||||||
|
// default: '',
|
||||||
|
// description: 'The unique identifier of a field in a table.',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// displayName: 'Grouping',
|
||||||
|
// name: 'grouping',
|
||||||
|
// type: 'options',
|
||||||
|
// options: [
|
||||||
|
// {
|
||||||
|
// name: 'ASC',
|
||||||
|
// value: 'ASC',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'DESC',
|
||||||
|
// value: 'DESC',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'Equal Values',
|
||||||
|
// value: 'equal-values',
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// default: 'ASC',
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
displayName: 'Select',
|
||||||
|
name: 'select',
|
||||||
|
type: 'multiOptions',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getTableFields',
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
description: 'An array of field ids for the fields that should be returned in the response. If empty, the default columns on the table will be returned.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Sort By',
|
||||||
|
name: 'sortByUi',
|
||||||
|
placeholder: 'Add Sort By',
|
||||||
|
type: 'fixedCollection',
|
||||||
|
typeOptions: {
|
||||||
|
multipleValues: true,
|
||||||
|
},
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'sortByValues',
|
||||||
|
displayName: 'Sort By',
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
displayName: 'Field ID',
|
||||||
|
name: 'fieldId',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getTableFields',
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'The unique identifier of a field in a table.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Order',
|
||||||
|
name: 'order',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'ASC',
|
||||||
|
value: 'ASC',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DESC',
|
||||||
|
value: 'DESC',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'ASC',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
description: `By default, queries will be sorted by the given sort fields or the default sort if the query does not provide any.<br>
|
||||||
|
Set to false to avoid sorting when the order of the data returned is not important. Returning data without sorting can improve performance.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Where',
|
||||||
|
name: 'where',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'The filter, using the <a href="https://help.quickbase.com/api-guide/componentsquery.html" target="_blank">Quick Base query language</a>, which determines the records to return.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* record:update */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Columns',
|
||||||
|
name: 'columns',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
placeholder: 'id,name,description',
|
||||||
|
description: 'Comma separated list of the properties which should used as columns for the new rows.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Update Key',
|
||||||
|
name: 'updateKey',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'update can use the key field on the table, or any other supported unique field.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Simple',
|
||||||
|
name: 'simple',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: true,
|
||||||
|
description: 'When set to true a simplify version of the response will be used else the raw data.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Options',
|
||||||
|
name: 'options',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Option',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Fields',
|
||||||
|
name: 'fields',
|
||||||
|
type: 'multiOptions',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getTableFields',
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'tableId',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
description: `Specify an array of field ids that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested.`,
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// displayName: 'Merge Field ID',
|
||||||
|
// name: 'mergeFieldId',
|
||||||
|
// type: 'options',
|
||||||
|
// typeOptions: {
|
||||||
|
// loadOptionsMethod: 'getUniqueTableFields',
|
||||||
|
// },
|
||||||
|
// default: '',
|
||||||
|
// description: `You're updating records in a Quick Base table with data from an external file. In order for a merge like this to work,<br>
|
||||||
|
// Quick Base needs a way to match records in the source data with corresponding records in the destination table. You make this possible by<br>
|
||||||
|
// choosing the field in the app table that holds unique matching values. This is called a merge field.`,
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* record:upsert */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'upsert',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Columns',
|
||||||
|
name: 'columns',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'upsert',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
placeholder: 'id,name,description',
|
||||||
|
description: 'Comma separated list of the properties which should used as columns for the new rows.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Update Key',
|
||||||
|
name: 'updateKey',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'upsert',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'update can use the key field on the table, or any other supported unique field.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Merge Field ID',
|
||||||
|
name: 'mergeFieldId',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getUniqueTableFields',
|
||||||
|
},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'upsert',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: `You're updating records in a Quick Base table with data from an external file. In order for a merge like this to work,<br>
|
||||||
|
Quick Base needs a way to match records in the source data with corresponding records in the destination table. You make this possible by<br>
|
||||||
|
choosing the field in the app table that holds unique matching values. This is called a merge field.`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Simple',
|
||||||
|
name: 'simple',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'upsert',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: true,
|
||||||
|
description: 'When set to true a simplify version of the response will be used else the raw data.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Options',
|
||||||
|
name: 'options',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Option',
|
||||||
|
default: {},
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'record',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'upsert',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Fields',
|
||||||
|
name: 'fields',
|
||||||
|
type: 'multiOptions',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getTableFields',
|
||||||
|
loadOptionsDependsOn: [
|
||||||
|
'tableId',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
default: [],
|
||||||
|
description: `Specify an array of field ids that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested.`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
156
packages/nodes-base/nodes/QuickBase/ReportDescription.ts
Normal file
156
packages/nodes-base/nodes/QuickBase/ReportDescription.ts
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
import {
|
||||||
|
INodeProperties,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export const reportOperations = [
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'report',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Get',
|
||||||
|
value: 'get',
|
||||||
|
description: 'Get a report',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Run',
|
||||||
|
value: 'run',
|
||||||
|
description: 'Run a report',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'get',
|
||||||
|
description: 'The operation to perform.',
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
|
|
||||||
|
export const reportFields = [
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* report:get */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'report',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'get',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Report ID',
|
||||||
|
name: 'reportId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'report',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'get',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The identifier of the report, unique to the table',
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* report:run */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Table ID',
|
||||||
|
name: 'tableId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'report',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'run',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The table identifier',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Report ID',
|
||||||
|
name: 'reportId',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'report',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'run',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The identifier of the report, unique to the table',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Return All',
|
||||||
|
name: 'returnAll',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'report',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'run',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: true,
|
||||||
|
description: 'If all results should be returned or only up to a given limit.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Limit',
|
||||||
|
name: 'limit',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'report',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'run',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
returnAll: [
|
||||||
|
true,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
typeOptions: {
|
||||||
|
minValue: 1,
|
||||||
|
maxValue: 100,
|
||||||
|
},
|
||||||
|
default: 100,
|
||||||
|
description: 'Number of results to return.',
|
||||||
|
},
|
||||||
|
] as INodeProperties[];
|
||||||
BIN
packages/nodes-base/nodes/QuickBase/quickbase.png
Normal file
BIN
packages/nodes-base/nodes/QuickBase/quickbase.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -162,6 +162,7 @@
|
|||||||
"dist/credentials/PushbulletOAuth2Api.credentials.js",
|
"dist/credentials/PushbulletOAuth2Api.credentials.js",
|
||||||
"dist/credentials/PushoverApi.credentials.js",
|
"dist/credentials/PushoverApi.credentials.js",
|
||||||
"dist/credentials/QuestDb.credentials.js",
|
"dist/credentials/QuestDb.credentials.js",
|
||||||
|
"dist/credentials/QuickBaseApi.credentials.js",
|
||||||
"dist/credentials/Redis.credentials.js",
|
"dist/credentials/Redis.credentials.js",
|
||||||
"dist/credentials/RocketchatApi.credentials.js",
|
"dist/credentials/RocketchatApi.credentials.js",
|
||||||
"dist/credentials/RundeckApi.credentials.js",
|
"dist/credentials/RundeckApi.credentials.js",
|
||||||
@@ -381,6 +382,7 @@
|
|||||||
"dist/nodes/Pushbullet/Pushbullet.node.js",
|
"dist/nodes/Pushbullet/Pushbullet.node.js",
|
||||||
"dist/nodes/Pushover/Pushover.node.js",
|
"dist/nodes/Pushover/Pushover.node.js",
|
||||||
"dist/nodes/QuestDb/QuestDb.node.js",
|
"dist/nodes/QuestDb/QuestDb.node.js",
|
||||||
|
"dist/nodes/QuickBase/QuickBase.node.js",
|
||||||
"dist/nodes/ReadBinaryFile.node.js",
|
"dist/nodes/ReadBinaryFile.node.js",
|
||||||
"dist/nodes/ReadBinaryFiles.node.js",
|
"dist/nodes/ReadBinaryFiles.node.js",
|
||||||
"dist/nodes/ReadPdf.node.js",
|
"dist/nodes/ReadPdf.node.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user