Skip to content

Commit

Permalink
✨ Supabase node
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoE105 committed Dec 10, 2021
1 parent 1659081 commit 5feeccb
Show file tree
Hide file tree
Showing 3 changed files with 462 additions and 281 deletions.
298 changes: 277 additions & 21 deletions packages/nodes-base/nodes/Supabase/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from 'n8n-core';

import {
IDataObject, NodeApiError,
IDataObject, INodeProperties, NodeApiError,
} from 'n8n-workflow';

export async function superbaseApiRequest(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
Expand All @@ -35,7 +35,6 @@ export async function superbaseApiRequest(this: IExecuteFunctions | IExecuteSing
if (Object.keys(body).length === 0) {
delete options.body;
}
console.log(options);
//@ts-ignore
return this.helpers?.request(options);

Expand All @@ -44,23 +43,280 @@ export async function superbaseApiRequest(this: IExecuteFunctions | IExecuteSing
}
}

// export async function stravaApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
// export const getWhereConditions = (
// displayName: string,
// operations: string[],
// placeholder: string,
// ): INodeProperties[] => {
// return [{
// displayName,
// name: 'keys',
// type: 'fixedCollection',
// placeholder,
// typeOptions: {
// multipleValues: true,
// },
// displayOptions: {
// show: {
// resource: [
// 'row',
// ],
// operation: operations,
// },
// },
// default: {},
// options: [
// {
// name: 'keys',
// displayName: 'Key',
// values: [
// {
// displayName: 'Key Name',
// name: 'keyName',
// type: 'string',
// default: '',
// },
// {
// displayName: 'Condition',
// name: 'condition',
// type: 'options',
// options: [
// {
// name: 'Equals',
// value: 'eq',
// },
// {
// name: 'Greater Than',
// value: 'gt',
// },
// {
// name: 'Greater Than Equal',
// value: 'gte',
// },
// {
// name: 'Less than',
// value: 'lt',
// },
// {
// name: 'Less Than or Equal',
// value: 'lte',
// },
// {
// name: 'Not Equal',
// value: '<>',
// },
// {
// name: 'LIKE operator',
// value: 'like',
// description: 'use * in place of %',
// },
// {
// name: 'ILIKE operator',
// value: 'ilike',
// description: 'use * in place of %',
// },
// {
// name: 'Is',
// value: 'is',
// description: 'Checking for exact equality (null,true,false,unknown)',
// },
// {
// name: 'Full-Text',
// value: '@@',
// },
// ],
// default: '',
// },
// {
// displayName: 'Key Value',
// name: 'keyValue',
// type: 'string',
// default: '',
// },
// ],
// },
// ],
// }];
// };

// const returnData: IDataObject[] = [];

// let responseData;

// query.per_page = 30;

// query.page = 1;

// do {
// responseData = await stravaApiRequest.call(this, method, resource, body, query);
// query.page++;
// returnData.push.apply(returnData, responseData);
// } while (
// responseData.length !== 0
// );

// return returnData;
// }
export function getFilters(
resources: string[],
operations: string[]): INodeProperties[] {
return [
{
displayName: 'Filter',
name: 'filterType',
type: 'options',
options: [
{
name: 'None',
value: 'none',
},
{
name: 'Build Manually',
value: 'manual',
},
{
name: 'String',
value: 'string',
},
],
displayOptions: {
show: {
resource: resources,
operation: operations,
},
},
default: 'none',
},
{
displayName: 'Must Match',
name: 'matchType',
type: 'options',
options: [
{
name: 'Any filter',
value: 'anyFilter',
},
{
name: 'All Filters',
value: 'allFilters',
},
],
displayOptions: {
show: {
resource: resources,
operation: operations,
filterType: [
'manual',
],
},
},
default: 'anyFilter',
},
{
displayName: 'Filters',
name: 'filters',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
displayOptions: {
show: {
resource: resources,
operation: operations,
filterType: [
'manual',
],
},
},
default: '',
placeholder: 'Add Condition',
options: [
{
displayName: 'Conditions',
name: 'conditions',
values: [
{
displayName: 'Key Name',
name: 'keyName',
type: 'string',
default: '',
},
{
displayName: 'Condition',
name: 'condition',
type: 'options',
options: [
{
name: 'Equals',
value: 'eq',
},
{
name: 'Greater Than',
value: 'gt',
},
{
name: 'Greater Than Equal',
value: 'gte',
},
{
name: 'Less than',
value: 'lt',
},
{
name: 'Less Than or Equal',
value: 'lte',
},
{
name: 'Not Equal',
value: '<>',
},
{
name: 'LIKE operator',
value: 'like',
description: 'use * in place of %',
},
{
name: 'ILIKE operator',
value: 'ilike',
description: 'use * in place of %',
},
{
name: 'Is',
value: 'is',
description: 'Checking for exact equality (null,true,false,unknown)',
},
{
name: 'Full-Text',
value: '@@',
},
],
default: '',
},
{
displayName: 'Key Value',
name: 'keyValue',
type: 'string',
default: '',
},
],
},
],
},
{
displayName: 'See <a href="https://postgrest.org/en/v9.0/api.html#horizontal-filtering-rows" target="_blank">PostgREST guide</a> to creating filters',
name: 'jsonNotice',
type: 'notice',
displayOptions: {
show: {
resource: resources,
operation: operations,
filterType: [
'string',
],
},
},
default: '',
},
{
displayName: 'Filters (String)',
name: 'filterString',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
displayOptions: {
show: {
resource: resources,
operation: operations,
filterType: [
'string',
],
},
},
default: '',
description: '',
},
];
}
Loading

0 comments on commit 5feeccb

Please sign in to comment.