mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
## Summary Unify `severity` and `level` for all backend application errors for Sentry Follow-up to: https://github.com/n8n-io/n8n/pull/7914#issuecomment-1840433542 ... #### How to test the change: 1. ... ## Issues fixed Include links to Github issue or Community forum post or **Linear ticket**: > Important in order to close automatically and provide context to reviewers ... ## Review / Merge checklist - [ ] PR title and summary are descriptive. **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** ([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md)) - [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up ticket created. - [ ] Tests included. > A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. > > *(internal)* You can use Slack commands to trigger [e2e tests](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#a39f9e5ba64a48b58a71d81c837e8227) or [deploy test instance](https://www.notion.so/n8n/How-to-use-Test-Instances-d65f49dfc51f441ea44367fb6f67eb0a?pvs=4#f6a177d32bde4b57ae2da0b8e454bfce) or [deploy early access version on Cloud](https://www.notion.so/n8n/Cloudbot-3dbe779836004972b7057bc989526998?pvs=4#fef2d36ab02247e1a0f65a74f6fb534e).
152 lines
3.5 KiB
TypeScript
152 lines
3.5 KiB
TypeScript
import type {
|
|
IDataObject,
|
|
ILoadOptionsFunctions,
|
|
INodeListSearchItems,
|
|
INodeListSearchResult,
|
|
} from 'n8n-workflow';
|
|
import { NodeOperationError } from 'n8n-workflow';
|
|
import { apiRequest } from '../transport';
|
|
|
|
export async function baseSearch(
|
|
this: ILoadOptionsFunctions,
|
|
filter?: string,
|
|
paginationToken?: string,
|
|
): Promise<INodeListSearchResult> {
|
|
let qs;
|
|
if (paginationToken) {
|
|
qs = {
|
|
offset: paginationToken,
|
|
};
|
|
}
|
|
|
|
const response = await apiRequest.call(this, 'GET', 'meta/bases', undefined, qs);
|
|
|
|
if (filter) {
|
|
const results: INodeListSearchItems[] = [];
|
|
|
|
for (const base of response.bases || []) {
|
|
if ((base.name as string)?.toLowerCase().includes(filter.toLowerCase())) {
|
|
results.push({
|
|
name: base.name as string,
|
|
value: base.id as string,
|
|
url: `https://airtable.com/${base.id}`,
|
|
});
|
|
}
|
|
}
|
|
|
|
return {
|
|
results,
|
|
paginationToken: response.offset,
|
|
};
|
|
} else {
|
|
return {
|
|
results: (response.bases || []).map((base: IDataObject) => ({
|
|
name: base.name as string,
|
|
value: base.id as string,
|
|
url: `https://airtable.com/${base.id}`,
|
|
})),
|
|
paginationToken: response.offset,
|
|
};
|
|
}
|
|
}
|
|
|
|
export async function tableSearch(
|
|
this: ILoadOptionsFunctions,
|
|
filter?: string,
|
|
paginationToken?: string,
|
|
): Promise<INodeListSearchResult> {
|
|
const baseId = this.getNodeParameter('base', undefined, {
|
|
extractValue: true,
|
|
}) as string;
|
|
|
|
let qs;
|
|
if (paginationToken) {
|
|
qs = {
|
|
offset: paginationToken,
|
|
};
|
|
}
|
|
|
|
const response = await apiRequest.call(this, 'GET', `meta/bases/${baseId}/tables`, undefined, qs);
|
|
|
|
if (filter) {
|
|
const results: INodeListSearchItems[] = [];
|
|
|
|
for (const table of response.tables || []) {
|
|
if ((table.name as string)?.toLowerCase().includes(filter.toLowerCase())) {
|
|
results.push({
|
|
name: table.name as string,
|
|
value: table.id as string,
|
|
url: `https://airtable.com/${baseId}/${table.id}`,
|
|
});
|
|
}
|
|
}
|
|
|
|
return {
|
|
results,
|
|
paginationToken: response.offset,
|
|
};
|
|
} else {
|
|
return {
|
|
results: (response.tables || []).map((table: IDataObject) => ({
|
|
name: table.name as string,
|
|
value: table.id as string,
|
|
url: `https://airtable.com/${baseId}/${table.id}`,
|
|
})),
|
|
paginationToken: response.offset,
|
|
};
|
|
}
|
|
}
|
|
|
|
export async function viewSearch(
|
|
this: ILoadOptionsFunctions,
|
|
filter?: string,
|
|
): Promise<INodeListSearchResult> {
|
|
const baseId = this.getNodeParameter('base', undefined, {
|
|
extractValue: true,
|
|
}) as string;
|
|
|
|
const tableId = encodeURI(
|
|
this.getNodeParameter('table', undefined, {
|
|
extractValue: true,
|
|
}) as string,
|
|
);
|
|
|
|
const response = await apiRequest.call(this, 'GET', `meta/bases/${baseId}/tables`);
|
|
|
|
const tableData = ((response.tables as IDataObject[]) || []).find((table: IDataObject) => {
|
|
return table.id === tableId;
|
|
});
|
|
|
|
if (!tableData) {
|
|
throw new NodeOperationError(this.getNode(), 'Table information could not be found!', {
|
|
level: 'warning',
|
|
});
|
|
}
|
|
|
|
if (filter) {
|
|
const results: INodeListSearchItems[] = [];
|
|
|
|
for (const view of (tableData.views as IDataObject[]) || []) {
|
|
if ((view.name as string)?.toLowerCase().includes(filter.toLowerCase())) {
|
|
results.push({
|
|
name: view.name as string,
|
|
value: view.id as string,
|
|
url: `https://airtable.com/${baseId}/${tableId}/${view.id}`,
|
|
});
|
|
}
|
|
}
|
|
|
|
return {
|
|
results,
|
|
};
|
|
} else {
|
|
return {
|
|
results: ((tableData.views as IDataObject[]) || []).map((view) => ({
|
|
name: view.name as string,
|
|
value: view.id as string,
|
|
url: `https://airtable.com/${baseId}/${tableId}/${view.id}`,
|
|
})),
|
|
};
|
|
}
|
|
}
|