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:
Ria Scholz
2025-04-14 17:56:07 +02:00
committed by GitHub
parent de03452631
commit 23f25cefbf
4 changed files with 141 additions and 8 deletions

View File

@@ -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);
}
}