@fachkraftfreund/n8n-nodes-supabase 1.2.11 → 1.2.13
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.
|
@@ -891,12 +891,6 @@ class Supabase {
|
|
|
891
891
|
async execute() {
|
|
892
892
|
const items = this.getInputData();
|
|
893
893
|
const returnData = [];
|
|
894
|
-
const firstItem = items[0];
|
|
895
|
-
if (items.length === 1 &&
|
|
896
|
-
(firstItem === null || firstItem === void 0 ? void 0 : firstItem.json) &&
|
|
897
|
-
Object.keys(firstItem.json).length === 0) {
|
|
898
|
-
return [[{ json: {} }]];
|
|
899
|
-
}
|
|
900
894
|
const credentials = await this.getCredentials('supabaseExtendedApi');
|
|
901
895
|
try {
|
|
902
896
|
(0, supabaseClient_1.validateCredentials)(credentials);
|
|
@@ -909,6 +903,12 @@ class Supabase {
|
|
|
909
903
|
const resource = this.getNodeParameter('resource', 0);
|
|
910
904
|
const operation = this.getNodeParameter('operation', 0);
|
|
911
905
|
if (resource === 'database' && ['create', 'upsert', 'update'].includes(operation)) {
|
|
906
|
+
const firstItem = items[0];
|
|
907
|
+
if (items.length === 1 &&
|
|
908
|
+
(firstItem === null || firstItem === void 0 ? void 0 : firstItem.json) &&
|
|
909
|
+
Object.keys(firstItem.json).length === 0) {
|
|
910
|
+
return [[{ json: {} }]];
|
|
911
|
+
}
|
|
912
912
|
try {
|
|
913
913
|
const results = await database_1.executeBulkDatabaseOperation.call(this, supabase, operation, items.length);
|
|
914
914
|
returnData.push(...results);
|
|
@@ -197,14 +197,14 @@ async function handleRead(supabase, itemIndex) {
|
|
|
197
197
|
const sort = this.getNodeParameter('sort.sortField', itemIndex, []);
|
|
198
198
|
const filterChunks = (0, supabaseClient_1.expandChunkedFilters)(filters);
|
|
199
199
|
const returnData = [];
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
if (returnAll) {
|
|
201
|
+
for (const chunkFilters of filterChunks) {
|
|
202
202
|
const batchSize = 1000;
|
|
203
|
-
let
|
|
203
|
+
let batchOffset = 0;
|
|
204
204
|
let hasMore = true;
|
|
205
205
|
while (hasMore) {
|
|
206
206
|
const batchQuery = buildReadQuery(supabase, table, returnFields, chunkFilters, sort, { count: 'exact' });
|
|
207
|
-
const { data: batchData, error: batchError } = await batchQuery.range(
|
|
207
|
+
const { data: batchData, error: batchError } = await batchQuery.range(batchOffset, batchOffset + batchSize - 1);
|
|
208
208
|
if (batchError) {
|
|
209
209
|
throw new Error((0, supabaseClient_1.formatSupabaseError)(batchError));
|
|
210
210
|
}
|
|
@@ -217,18 +217,26 @@ async function handleRead(supabase, itemIndex) {
|
|
|
217
217
|
else {
|
|
218
218
|
hasMore = false;
|
|
219
219
|
}
|
|
220
|
-
|
|
220
|
+
batchOffset += batchSize;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const limit = this.getNodeParameter('limit', itemIndex, 100);
|
|
226
|
+
const userOffset = this.getNodeParameter('offset', itemIndex, 0);
|
|
227
|
+
const isMultiChunk = filterChunks.length > 1;
|
|
228
|
+
for (const chunkFilters of filterChunks) {
|
|
226
229
|
let query = buildReadQuery(supabase, table, returnFields, chunkFilters, sort);
|
|
227
|
-
if (
|
|
228
|
-
query = query.limit(limit);
|
|
230
|
+
if (isMultiChunk) {
|
|
231
|
+
query = query.limit(userOffset + limit);
|
|
229
232
|
}
|
|
230
|
-
|
|
231
|
-
|
|
233
|
+
else {
|
|
234
|
+
if (userOffset > 0) {
|
|
235
|
+
query = query.range(userOffset, userOffset + limit - 1);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
query = query.limit(limit);
|
|
239
|
+
}
|
|
232
240
|
}
|
|
233
241
|
const { data, error } = await query;
|
|
234
242
|
if (error) {
|
|
@@ -240,6 +248,11 @@ async function handleRead(supabase, itemIndex) {
|
|
|
240
248
|
}
|
|
241
249
|
}
|
|
242
250
|
}
|
|
251
|
+
if (isMultiChunk && (userOffset > 0 || returnData.length > limit)) {
|
|
252
|
+
const sliced = returnData.slice(userOffset, userOffset + limit);
|
|
253
|
+
returnData.length = 0;
|
|
254
|
+
returnData.push(...sliced);
|
|
255
|
+
}
|
|
243
256
|
}
|
|
244
257
|
if (returnData.length === 0) {
|
|
245
258
|
returnData.push({
|
|
@@ -180,12 +180,28 @@ function expandChunkedFilters(filters) {
|
|
|
180
180
|
const staticFilters = [];
|
|
181
181
|
const chunkedEntries = [];
|
|
182
182
|
for (const filter of filters) {
|
|
183
|
-
if (filter.operator === 'in'
|
|
184
|
-
|
|
183
|
+
if (filter.operator === 'in') {
|
|
184
|
+
let values;
|
|
185
|
+
if (Array.isArray(filter.value)) {
|
|
186
|
+
values = filter.value;
|
|
187
|
+
}
|
|
188
|
+
else if (typeof filter.value === 'string') {
|
|
189
|
+
let str = filter.value.trim();
|
|
190
|
+
if (str.startsWith('(') && str.endsWith(')'))
|
|
191
|
+
str = str.slice(1, -1);
|
|
192
|
+
if (str.startsWith('[') && str.endsWith(']'))
|
|
193
|
+
str = str.slice(1, -1);
|
|
194
|
+
values = str.split(',').map(v => v.trim()).filter(v => v.length > 0);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
staticFilters.push(filter);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const serialized = values.map(String).join(',');
|
|
185
201
|
if (serialized.length > exports.IN_FILTER_MAX_CHAR_LENGTH) {
|
|
186
202
|
chunkedEntries.push({
|
|
187
|
-
filter,
|
|
188
|
-
chunks: chunkInFilterValues(
|
|
203
|
+
filter: { ...filter, value: values },
|
|
204
|
+
chunks: chunkInFilterValues(values),
|
|
189
205
|
});
|
|
190
206
|
continue;
|
|
191
207
|
}
|
package/package.json
CHANGED