Skip to content

Commit

Permalink
⚡ Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 committed Jan 4, 2022
1 parent da75e67 commit 5bb09f0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 16 deletions.
34 changes: 21 additions & 13 deletions packages/nodes-base/nodes/Supabase/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
INodeProperties,
NodeApiError,
} from 'n8n-workflow';
import { IData } from '../Google/Analytics/Interfaces';

export async function supabaseApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('supabaseApi') as { host: string, serviceRole: string };
Expand Down Expand Up @@ -56,13 +57,29 @@ const mapOperations: { [key: string]: string } = {

export function getFilters(
resources: string[],
operations: string[]): INodeProperties[] {
operations: string[],
{
includeNoneOption = true,
filterTypeDisplayName = 'Filter',
fixedCollectionDisplayName = 'Filters',
mustMatchOptions = [
{
name: 'Any Filter',
value: 'anyFilter',
},
{
name: 'All Filters',
value: 'allFilters',
},
],
}): INodeProperties[] {
return [
{
displayName: 'Filter',
displayName: filterTypeDisplayName,
name: 'filterType',
type: 'options',
options: [
...(includeNoneOption ? [{ name: 'None', value: 'none' }] : []),
{
name: 'Build Manually',
value: 'manual',
Expand All @@ -84,16 +101,7 @@ export function getFilters(
displayName: 'Must Match',
name: 'matchType',
type: 'options',
options: [
{
name: 'Any Filter',
value: 'anyFilter',
},
{
name: 'All Filters',
value: 'allFilters',
},
],
options: mustMatchOptions,
displayOptions: {
show: {
resource: resources,
Expand All @@ -106,7 +114,7 @@ export function getFilters(
default: 'anyFilter',
},
{
displayName: 'Filters',
displayName: fixedCollectionDisplayName,
name: 'filters',
type: 'fixedCollection',
typeOptions: {
Expand Down
39 changes: 36 additions & 3 deletions packages/nodes-base/nodes/Supabase/RowDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,24 @@ export const rowFields: INodeProperties[] = [
},
default: '',
},
...getFilters(['row'], ['update']),
...getFilters(
['row'],
['update'],
{
includeNoneOption: false,
filterTypeDisplayName: 'Select Type',
fixedCollectionDisplayName: 'Select Conditions',
mustMatchOptions: [
{
name: 'Any Select Condition',
value: 'anyFilter',
},
{
name: 'All Select Conditions',
value: 'allFilters',
},
],
}),
{
displayName: 'Data to Send',
name: 'dataToSend',
Expand Down Expand Up @@ -187,7 +204,23 @@ export const rowFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* row:delete */
/* -------------------------------------------------------------------------- */
...getFilters(['row'], ['delete']),
...getFilters(
['row'],
['delete'],
{
includeNoneOption: false,
filterTypeDisplayName: 'Select Type',
fixedCollectionDisplayName: 'Select Conditions',
mustMatchOptions: [
{
name: 'Any Select Condition',
value: 'anyFilter',
},
{
name: 'All Select Conditions',
value: 'allFilters',
},
]}),
/* -------------------------------------------------------------------------- */
/* row:get */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -282,5 +315,5 @@ export const rowFields: INodeProperties[] = [
default: 50,
description: 'How many results to return',
},
...getFilters(['row'], ['getAll']),
...getFilters(['row'], ['getAll'], {}),
];

0 comments on commit 5bb09f0

Please sign in to comment.