@fachkraftfreund/n8n-nodes-supabase 1.3.11 → 1.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -107,17 +107,18 @@ function parseFilters(context, itemIndex) {
|
|
|
107
107
|
throw new Error('Invalid advanced filters JSON');
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
const
|
|
110
|
+
const DEFAULT_BATCH_SIZE = 1000;
|
|
111
111
|
async function* fetchBatches(supabase, table, selectFields, filters, sort, hostUrl, returnAll, limit, joins) {
|
|
112
112
|
const overhead = (0, supabaseClient_2.estimateUrlOverhead)(hostUrl, table, selectFields, filters, sort);
|
|
113
113
|
const maxInChars = Math.max(500, supabaseClient_2.MAX_SAFE_URL_LENGTH - overhead);
|
|
114
114
|
const maxItems = (0, supabaseClient_2.computeMaxIdsPerChunk)(selectFields);
|
|
115
115
|
const filterChunks = (0, supabaseClient_2.expandChunkedFilters)(filters, maxInChars, maxItems);
|
|
116
|
+
const BATCH_SIZE = (0, supabaseClient_2.computeBatchSize)(selectFields);
|
|
116
117
|
const hasIdColumn = selectFields === '*' || selectFields.split(',').some((f) => f.trim() === 'id');
|
|
117
118
|
let totalYielded = 0;
|
|
118
119
|
const maxRows = returnAll ? Infinity : limit;
|
|
119
120
|
const startTime = Date.now();
|
|
120
|
-
console.log(`[Supabase CSV] starting export table=${table} returnAll=${returnAll} chunks=${filterChunks.length} keyset=${hasIdColumn}`);
|
|
121
|
+
console.log(`[Supabase CSV] starting export table=${table} returnAll=${returnAll} chunks=${filterChunks.length} keyset=${hasIdColumn} batchSize=${BATCH_SIZE}`);
|
|
121
122
|
for (let ci = 0; ci < filterChunks.length; ci++) {
|
|
122
123
|
const chunkFilters = filterChunks[ci];
|
|
123
124
|
if (totalYielded >= maxRows)
|
|
@@ -369,10 +369,10 @@ async function handleRead(supabase, itemIndex, hostUrl) {
|
|
|
369
369
|
const maxInChars = Math.max(500, supabaseClient_1.MAX_SAFE_URL_LENGTH - overhead);
|
|
370
370
|
const maxItems = (0, supabaseClient_1.computeMaxIdsPerChunk)(selectWithJoins);
|
|
371
371
|
const filterChunks = (0, supabaseClient_1.expandChunkedFilters)(filters, maxInChars, maxItems);
|
|
372
|
-
|
|
372
|
+
const batchSize = (0, supabaseClient_1.computeBatchSize)(selectWithJoins);
|
|
373
|
+
console.log(`[Supabase READ] item=${itemIndex} table=${table} returnAll=${returnAll} chunks=${filterChunks.length} maxItems=${maxItems} maxInChars=${maxInChars} batchSize=${batchSize}`);
|
|
373
374
|
const returnData = [];
|
|
374
375
|
if (returnAll) {
|
|
375
|
-
const batchSize = 1000;
|
|
376
376
|
const selectFields = returnFields && returnFields !== '*' ? returnFields : '*';
|
|
377
377
|
const hasIdColumn = selectFields === '*' || selectFields.split(',').some(f => f.trim() === 'id');
|
|
378
378
|
for (let ci = 0; ci < filterChunks.length; ci++) {
|
|
@@ -14,6 +14,7 @@ export declare function convertFilterOperator(operator: string): string;
|
|
|
14
14
|
export declare function normalizeFilterValue(operator: string, value: string | number | boolean | null | unknown[]): string | number | boolean | null;
|
|
15
15
|
export declare const MAX_SAFE_URL_LENGTH = 7500;
|
|
16
16
|
export declare function computeMaxIdsPerChunk(selectFields?: string): number;
|
|
17
|
+
export declare function computeBatchSize(selectFields?: string): number;
|
|
17
18
|
export declare function estimateUrlOverhead(hostUrl: string, table: string, selectFields?: string, filters?: IRowFilter[], sort?: IRowSort[]): number;
|
|
18
19
|
export declare function chunkInFilterValues(values: unknown[], maxChars: number, maxItems?: number): unknown[][];
|
|
19
20
|
export declare function expandChunkedFilters(filters: IRowFilter[], maxInChars?: number, maxItems?: number): IRowFilter[][];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expandChunkedFilters = exports.chunkInFilterValues = exports.estimateUrlOverhead = exports.computeMaxIdsPerChunk = exports.MAX_SAFE_URL_LENGTH = exports.normalizeFilterValue = exports.convertFilterOperator = exports.validateColumnName = exports.validateTableName = exports.sanitizeColumnName = exports.isNetworkError = exports.isAuthError = exports.formatSupabaseError = exports.getDatabaseUrl = exports.getStorageUrl = exports.validateCredentials = exports.createSupabaseClient = void 0;
|
|
3
|
+
exports.expandChunkedFilters = exports.chunkInFilterValues = exports.estimateUrlOverhead = exports.computeBatchSize = exports.computeMaxIdsPerChunk = exports.MAX_SAFE_URL_LENGTH = exports.normalizeFilterValue = exports.convertFilterOperator = exports.validateColumnName = exports.validateTableName = exports.sanitizeColumnName = exports.isNetworkError = exports.isAuthError = exports.formatSupabaseError = exports.getDatabaseUrl = exports.getStorageUrl = exports.validateCredentials = exports.createSupabaseClient = void 0;
|
|
4
4
|
const supabase_js_1 = require("@supabase/supabase-js");
|
|
5
5
|
function createSupabaseClient(credentials) {
|
|
6
6
|
const client = (0, supabase_js_1.createClient)(credentials.host, credentials.serviceKey, {
|
|
@@ -171,6 +171,16 @@ function computeMaxIdsPerChunk(selectFields) {
|
|
|
171
171
|
return Math.max(100, Math.floor(BASE_LIMIT / (1 + joinCount * 1.5)));
|
|
172
172
|
}
|
|
173
173
|
exports.computeMaxIdsPerChunk = computeMaxIdsPerChunk;
|
|
174
|
+
function computeBatchSize(selectFields) {
|
|
175
|
+
const BASE = 2000;
|
|
176
|
+
if (!selectFields || selectFields === '*')
|
|
177
|
+
return BASE;
|
|
178
|
+
const joinCount = (selectFields.match(/\(/g) || []).length;
|
|
179
|
+
if (joinCount === 0)
|
|
180
|
+
return BASE;
|
|
181
|
+
return Math.max(50, Math.floor(BASE / (1 + joinCount * 0.5)));
|
|
182
|
+
}
|
|
183
|
+
exports.computeBatchSize = computeBatchSize;
|
|
174
184
|
function estimateUrlOverhead(hostUrl, table, selectFields, filters, sort) {
|
|
175
185
|
let overhead = hostUrl.length + '/rest/v1/'.length + table.length + 1;
|
|
176
186
|
if (selectFields) {
|
package/package.json
CHANGED