2023-01-27 03:22:44 -08:00
|
|
|
import type { OptionsWithUri } from 'request';
|
2021-08-01 07:16:07 -07:00
|
|
|
|
2023-03-09 09:13:15 -08:00
|
|
|
import type {
|
|
|
|
IBinaryKeyData,
|
|
|
|
IDataObject,
|
|
|
|
IExecuteFunctions,
|
|
|
|
IHookFunctions,
|
|
|
|
ILoadOptionsFunctions,
|
|
|
|
INodeExecutionData,
|
2024-01-19 03:47:25 -08:00
|
|
|
IPairedItemData,
|
2023-03-09 09:13:15 -08:00
|
|
|
IPollFunctions,
|
|
|
|
} from 'n8n-workflow';
|
2023-01-27 03:22:44 -08:00
|
|
|
import { jsonParse, NodeOperationError } from 'n8n-workflow';
|
2021-08-01 07:16:07 -07:00
|
|
|
|
|
|
|
interface IAttachment {
|
|
|
|
url: string;
|
|
|
|
title: string;
|
|
|
|
mimetype: string;
|
|
|
|
size: number;
|
2024-01-05 01:15:10 -08:00
|
|
|
signedUrl?: string;
|
2021-08-01 07:16:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make an API request to NocoDB
|
|
|
|
*
|
|
|
|
*/
|
2022-08-17 08:50:24 -07:00
|
|
|
export async function apiRequest(
|
|
|
|
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions,
|
|
|
|
method: string,
|
|
|
|
endpoint: string,
|
|
|
|
body: object,
|
|
|
|
query?: IDataObject,
|
|
|
|
uri?: string,
|
|
|
|
option: IDataObject = {},
|
|
|
|
): Promise<any> {
|
feat(NocoDB Node): Add support v0.90.0+ (#3146)
* feat(NocoDB Node): add support for new NocoDB API
* fix(NocoDB Node): fix binary row update on old NocoDB API
* fix(NocoDB Node): fix getAll endpoint
* feat(NocoDB Node): allow xc-token as credential
* fix(NocoDB Node): get all for new api
* feat(NocoDB Node): list options & change to single data apis
* Moved to new format and reduced some code reuse
* Added API Version to Node Settings
* Improvements to remove code reuse and use bulk endpoints
* Added new credentials to close off PR#2909
* Credential testing working
* :zap: Improvements
* :zap: Add generic authentication type to credentials
* :fire: Remove credentials verification
* Fixed Get All not working with manual limit
* Removed json object from project / table fields
* added fix from n8n-4159
* :shirt: Fix linting issue
* feat: Improvements to pairedItem
* refactor: Consolidate hoisted package versions (#3724)
* :package: Consolidate hoisted package versions
* :package: Update `package-lock.json`
* :package: Update `package-lock.json`
* :package: Update `package-lock.json`
* refactor: Upgrade to ESLint 8 (#3722)
* :arrow_up: Upgrade to ESLint 8
* :package: Update package-lock.json
* :shirt: Add lint exceptions
* :shirt: Add more lint exceptions
* :heavy_minus_sign: Remove `tslint` from some packages
* :shirt: Except init file
* :package: Update `package-lock.json`
* :package: Update `package-lock.json`
* :shirt: Add exceptions to new lines coming from `master `
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
* refactor: Format all credentials (#3720)
* Apply Prettier to all credentials
* Fix quotes for lint
* :shirt: Remove `quotemark` rule
* :shirt: Run Prettier to take over quotes
* :arrow_up: Upgrade `eslint-plugin-n8n-nodes-base`
* :package: Update `package-lock.json`
Co-authored-by: Omar Ajoue <krynble@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
* fix: Fix node_type property in all events (#3759)
* :arrow_up: Update package-lock.json file
* fix(Mautic Node): Fix authentication issue (#3761)
* Fixes mautic credential issue
* removed unused imports
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
* fix(AWS DynamoDB Node): Fix expression attribute names (#3763)
* Fix expression attribute names in getAll
* fix: EAN value should be a string, not object
* Removed extra code for working out what credentials are in use
* fix(editor): Fix linking buttons color (#3770)
* fix color of icon
* center buttons
* fix(editor): Restore pindata header colors (#3758)
* :art: Restore `color-secondary-tint` colors
* :fire: Remove typing from JS file
* fix(editor): Fix sticky duplication and position bug (#3755)
* fix bug when inserting sticky
* center sticky on insert
* export as const
* refactor(editor): Move all colors to css variables (#3723)
* update white color
* update white color
* update more whites
* update color
* update curr running
* update text color #555
* update white color
* set search bar colors
* update colors
* update node executing
* update text colors
* update light color
* update theme
* update theme
* update overlays carousel
* update theme vars
* add dark theme tokens
* update text
* update table colors
* fix conflict
* update colors
* feat(Metabase Node): Add Metabase Node (#3033)
* Boilerplate with new node's version for metabse
* Metabases MVP features
* Added new credential for metabse, added custom auth for metabase
* Fixed bug with one enpoint not working
* Clean up code
* Uniformised the renovate token
* Made two example of responses for review
* Fixed lint issues
* Feature add datasources
* Changed output from databases
* Changed questions data output
* Fixed issue when testing credentials with new node format
* Add the possibility to get raw data
* Removed handle for the metabase meta results, changed export's name
* Add binary extraction for the result data
* Fixed binary download issue
* :zap: Add preAuthentication method to credentials
* Revert "Added new credential for metabse, added custom auth for metabase"
This reverts commit 5f1b7607adb85d6ec897b184853bdfdbae77df6d.
* Revert "Added new credential for metabse, added custom auth for metabase"
This reverts commit 5f1b7607adb85d6ec897b184853bdfdbae77df6d.
* Added preAuth and fixed autfixable linting rules
* Fixed linting errors
* Linting fixes
* Remove / at the end of url, and add placeholder for cred url
* Make export to Json retun only json and no binary
* Fix lint issues
* Add action and exception for lint rule
* Remove unnecessary credential file
* :zap: Simplify and cleanup
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
Co-authored-by: Omar Ajoue <krynble@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
* fix(editor): Fix spaces bug (#3774)
* refactor(editor): Change welcome sticky content (#3769)
* Updated Welcome sticky content
* Updated welcome sticky thumbnail image
Image was swapped out, used exact same file name + sizing so did not require code changes.
* Replaced welcome sticky thumbnail image
* fix(Fix Rocketchat Node): Fix authentication issue (#3778)
* Add suggested VSCode settings (#3783)
* :zap: Add suggested settings
* :fire: Remove app-level setting
* :art: Update indentation
* fix(core): Add windows support to import:credentials --separate (#3589)
* feat(Item List Node): Add operation for creating array from input items (#3149)
* :hammer: create array operation
* :hammer: removed semicolumn
* :hammer: updated UI
* :zap: display option fix
* :zap: aggregate operation description update, default aggregate item
* refactor: Add Onboarding call prompts (#3682)
* ✨ Implemented initial onboarding call prompt logic
* ✨ Added onboarding call prompt feature environment variable
* ✨ Implemented onboarding session signup modal
* 📈 Added initial telemetry for the onboarding call prompt
* ✔️ Fixing linter error in server.ts
* 💄 Updating onboaring call prompt and modal wording and styling
* ✨ Implemented initial version of fake doors feature
* ✨ Added parameters to onboarding call prompt request
* ✨ Finished implementing fake doors in settings
* 🔨 Updating onboarding call prompt fetching logic (fetching before timeout starts)
* 👌 Updating onboarding call prompt and fake door components based on the front-end review feedback
* ✨ Updated fake doors so they support UI location specification. Added credentials UI fake doors.
* ⚡ Added checkbox to the signup form, improved N8NCheckbox formatting to better handle overflow
* 💄 Moving seignup checkbox label text to i18n file, updating checkbox component css to force text wrap
* ✨ Update API calls to work with the new workflow request and response formats
* 👌 Updating fake door front-end based on the review feedback
* 👌 Updating onboarding call prompt and fake doors UI based in the product feedback
* ✨ Updated onboarding call prompts front-end to work with new endpoints and added new telemetry events
* 🐛 Fixing onboarding call prompts not appearing in first user sessions
* ⚡️ add createdAt to PublicUser
* 👌 Updating onboarding call prompts front-end to work with the latest back-end and addressing latest product review
* ✨ Improving error handling when submitting user emails on signup
* 💄 Updating info text on Logging feature page
* 💄 Updating first onboarding call prompt timeout to 5 minutes
* 💄 Fixing `N8nCheckbox` component font overflow
Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
* feat(Kafka Trigger Node): Add additional options (#3600)
* :hammer: additional options to kafka trigger
* :zap: option for maxInFlightRequests
* :zap: Small change
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
* fix(editor): Fix pin data in executions when pinData is null. (#3787)
* :arrow_up: Update package-lock.json file
* :bookmark: Release n8n-workflow@0.110.0
* :arrow_up: Set n8n-workflow@0.110.0 on n8n-core
* :bookmark: Release n8n-core@0.128.0
* :arrow_up: Set n8n-core@0.128.0 and n8n-workflow@0.110.0 on n8n-node-dev
* :bookmark: Release n8n-node-dev@0.67.0
* :arrow_up: Set n8n-core@0.128.0 and n8n-workflow@0.110.0 on n8n-nodes-base
* :bookmark: Release n8n-nodes-base@0.186.0
* :bookmark: Release n8n-design-system@0.28.0
* :arrow_up: Set n8n-design-system@0.28.0 and n8n-workflow@0.110.0 on n8n-editor-ui
* :bookmark: Release n8n-editor-ui@0.154.0
* :arrow_up: Set n8n-core@0.128.0, n8n-editor-ui@0.154.0, n8n-nodes-base@0.186.0 and n8n-workflow@0.110.0 on n8n
* :bookmark: Release n8n@0.188.0
* :bookmark: Update main package.json to 0.188.0
* :books: Update CHANGELOG.md with version 0.188.0
* :shirt: Adjust line endings for Prettier lintings (#3786)
* build: Use package-lock.json file with custom build
* 💄 Updating onboarding prompt label
* :arrow_up: Set eslint@8.0.0 on n8n-workflow (#3768)
* :arrow_up: Upgrade `n8n-workflow` to ESLint 8
* :package: Update `package-lock.json`
* :package: Re-update `package-lock.json`
* :zap: Fix on error behaviour for Delete, Get and Update
Co-authored-by: Jonathan Bennetts <jonathan.bennetts@gmail.com>
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
Co-authored-by: Ricardo Espinoza <ricardo@n8n.io>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
Co-authored-by: Omar Ajoue <krynble@gmail.com>
Co-authored-by: Ahsan Virani <ahsan.virani@gmail.com>
Co-authored-by: Nicholas Penree <nick@penree.com>
Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com>
Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
Co-authored-by: maxtkacz <maxtkacz@gmail.com>
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com>
Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com>
Co-authored-by: Milorad FIlipović <miloradfilipovic19@gmail.com>
Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
Co-authored-by: Alex Grozav <alex@grozav.com>
Co-authored-by: Milorad Filipovic <milorad@n8n.io>
2022-08-03 03:57:57 -07:00
|
|
|
const authenticationMethod = this.getNodeParameter('authentication', 0) as string;
|
|
|
|
const credentials = await this.getCredentials(authenticationMethod);
|
|
|
|
|
|
|
|
if (credentials === undefined) {
|
|
|
|
throw new NodeOperationError(this.getNode(), 'No credentials got returned!');
|
|
|
|
}
|
|
|
|
|
|
|
|
const baseUrl = credentials.host as string;
|
|
|
|
|
2023-01-19 04:37:19 -08:00
|
|
|
query = query || {};
|
2021-08-01 07:16:07 -07:00
|
|
|
|
2024-01-05 01:15:10 -08:00
|
|
|
if (!uri) {
|
|
|
|
uri = baseUrl.endsWith('/') ? `${baseUrl.slice(0, -1)}${endpoint}` : `${baseUrl}${endpoint}`;
|
|
|
|
}
|
|
|
|
|
2021-08-01 07:16:07 -07:00
|
|
|
const options: OptionsWithUri = {
|
|
|
|
method,
|
|
|
|
body,
|
|
|
|
qs: query,
|
2024-01-05 01:15:10 -08:00
|
|
|
uri,
|
2021-08-01 07:16:07 -07:00
|
|
|
json: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (Object.keys(option).length !== 0) {
|
|
|
|
Object.assign(options, option);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Object.keys(body).length === 0) {
|
|
|
|
delete options.body;
|
|
|
|
}
|
|
|
|
|
2024-01-17 07:08:50 -08:00
|
|
|
return await this.helpers.requestWithAuthentication.call(this, authenticationMethod, options);
|
2021-08-01 07:16:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make an API request to paginated NocoDB endpoint
|
|
|
|
* and return all results
|
|
|
|
*
|
|
|
|
* @param {(IHookFunctions | IExecuteFunctions)} this
|
|
|
|
*/
|
2022-08-17 08:50:24 -07:00
|
|
|
export async function apiRequestAllItems(
|
|
|
|
this: IHookFunctions | IExecuteFunctions | IPollFunctions,
|
|
|
|
method: string,
|
|
|
|
endpoint: string,
|
|
|
|
body: IDataObject,
|
|
|
|
query?: IDataObject,
|
|
|
|
): Promise<any> {
|
2022-12-02 12:54:28 -08:00
|
|
|
const version = this.getNode().typeVersion;
|
2021-08-01 07:16:07 -07:00
|
|
|
|
|
|
|
if (query === undefined) {
|
|
|
|
query = {};
|
|
|
|
}
|
|
|
|
query.limit = 100;
|
2022-08-17 08:50:24 -07:00
|
|
|
query.offset = query?.offset ? (query.offset as number) : 0;
|
2021-08-01 07:16:07 -07:00
|
|
|
const returnData: IDataObject[] = [];
|
|
|
|
|
|
|
|
let responseData;
|
|
|
|
|
|
|
|
do {
|
|
|
|
responseData = await apiRequest.call(this, method, endpoint, body, query);
|
2023-02-27 19:39:43 -08:00
|
|
|
version === 1
|
|
|
|
? returnData.push(...(responseData as IDataObject[]))
|
|
|
|
: returnData.push(...(responseData.list as IDataObject[]));
|
2021-08-01 07:16:07 -07:00
|
|
|
|
|
|
|
query.offset += query.limit;
|
2022-08-17 08:50:24 -07:00
|
|
|
} while (version === 1 ? responseData.length !== 0 : responseData.pageInfo.isLastPage !== true);
|
2021-08-01 07:16:07 -07:00
|
|
|
|
|
|
|
return returnData;
|
|
|
|
}
|
|
|
|
|
2022-08-17 08:50:24 -07:00
|
|
|
export async function downloadRecordAttachments(
|
|
|
|
this: IExecuteFunctions | IPollFunctions,
|
|
|
|
records: IDataObject[],
|
|
|
|
fieldNames: string[],
|
2024-01-19 03:47:25 -08:00
|
|
|
pairedItem?: IPairedItemData[],
|
2022-08-17 08:50:24 -07:00
|
|
|
): Promise<INodeExecutionData[]> {
|
2021-08-01 07:16:07 -07:00
|
|
|
const elements: INodeExecutionData[] = [];
|
|
|
|
|
|
|
|
for (const record of records) {
|
|
|
|
const element: INodeExecutionData = { json: {}, binary: {} };
|
2024-01-19 03:47:25 -08:00
|
|
|
if (pairedItem) {
|
|
|
|
element.pairedItem = pairedItem;
|
|
|
|
}
|
2021-08-01 07:16:07 -07:00
|
|
|
element.json = record as unknown as IDataObject;
|
|
|
|
for (const fieldName of fieldNames) {
|
2024-01-05 01:15:10 -08:00
|
|
|
let attachments = record[fieldName] as IAttachment[];
|
|
|
|
if (typeof attachments === 'string') {
|
|
|
|
attachments = jsonParse<IAttachment[]>(record[fieldName] as string);
|
|
|
|
}
|
2021-08-01 07:16:07 -07:00
|
|
|
if (record[fieldName]) {
|
2024-01-05 01:15:10 -08:00
|
|
|
for (const [index, attachment] of attachments.entries()) {
|
|
|
|
const attachmentUrl = attachment.signedUrl || attachment.url;
|
|
|
|
const file: Buffer = await apiRequest.call(this, 'GET', '', {}, {}, attachmentUrl, {
|
2022-08-17 08:50:24 -07:00
|
|
|
json: false,
|
|
|
|
encoding: null,
|
|
|
|
});
|
|
|
|
element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData(
|
|
|
|
Buffer.from(file),
|
|
|
|
attachment.title,
|
|
|
|
attachment.mimetype,
|
|
|
|
);
|
2021-08-01 07:16:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Object.keys(element.binary as IBinaryKeyData).length === 0) {
|
|
|
|
delete element.binary;
|
|
|
|
}
|
|
|
|
elements.push(element);
|
|
|
|
}
|
|
|
|
return elements;
|
|
|
|
}
|