mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(Supabase Node): Add support for database schema (#13339)
Co-authored-by: Dana <152518854+dana-gill@users.noreply.github.com> Co-authored-by: Dana Lee <dana@n8n.io>
This commit is contained in:
@@ -28,6 +28,15 @@ export async function supabaseApiRequest(
|
||||
serviceRole: string;
|
||||
}>('supabaseApi');
|
||||
|
||||
if (this.getNodeParameter('useCustomSchema', false)) {
|
||||
const schema = this.getNodeParameter('schema', 'public');
|
||||
if (['POST', 'PATCH', 'PUT', 'DELETE'].includes(method)) {
|
||||
headers['Content-Profile'] = schema;
|
||||
} else if (['GET', 'HEAD'].includes(method)) {
|
||||
headers['Accept-Profile'] = schema;
|
||||
}
|
||||
}
|
||||
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
Prefer: 'return=representation',
|
||||
@@ -35,18 +44,20 @@ export async function supabaseApiRequest(
|
||||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: uri || `${credentials.host}/rest/v1${resource}`,
|
||||
uri: uri ?? `${credentials.host}/rest/v1${resource}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
if (Object.keys(headers).length !== 0) {
|
||||
options.headers = Object.assign({}, options.headers, headers);
|
||||
}
|
||||
options.headers = Object.assign({}, options.headers, headers);
|
||||
if (Object.keys(body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
return await this.helpers.requestWithAuthentication.call(this, 'supabaseApi', options);
|
||||
} catch (error) {
|
||||
if (error.description) {
|
||||
error.message = `${error.message}: ${error.description}`;
|
||||
}
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user