@beltar/n8n-nodes-extract-archive 1.2.0 → 1.3.0

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.
@@ -4,6 +4,8 @@ export declare class ExtractArchive implements INodeType {
4
4
  private detectArchiveType;
5
5
  private extractZip;
6
6
  private extractRar;
7
+ private extractNestedZips;
8
+ private findZipFiles;
7
9
  private getAllFiles;
8
10
  private matchesFilter;
9
11
  private getMimeType;
@@ -196,6 +196,13 @@ class ExtractArchive {
196
196
  },
197
197
  },
198
198
  },
199
+ {
200
+ displayName: 'Recursive Extract',
201
+ name: 'recursiveExtract',
202
+ type: 'boolean',
203
+ default: false,
204
+ description: 'Whether to recursively extract nested ZIP archives found inside the extracted files until no more ZIP files remain',
205
+ },
199
206
  {
200
207
  displayName: 'Include Subdirectories',
201
208
  name: 'includeSubdirectories',
@@ -263,6 +270,34 @@ class ExtractArchive {
263
270
  // Iterating drives extraction; nothing else needed since targetPath handles file writing
264
271
  }
265
272
  }
273
+ async extractNestedZips(dir, password) {
274
+ let foundZip = true;
275
+ while (foundZip) {
276
+ foundZip = false;
277
+ const zipFiles = this.findZipFiles(dir);
278
+ for (const zipPath of zipFiles) {
279
+ foundZip = true;
280
+ const extractTarget = zipPath.replace(/\.zip$/i, '');
281
+ fs.mkdirSync(extractTarget, { recursive: true });
282
+ await this.extractZip(zipPath, extractTarget, password);
283
+ fs.unlinkSync(zipPath);
284
+ }
285
+ }
286
+ }
287
+ findZipFiles(dir) {
288
+ const results = [];
289
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
290
+ for (const entry of entries) {
291
+ const fullPath = path.join(dir, entry.name);
292
+ if (entry.isDirectory()) {
293
+ results.push(...this.findZipFiles(fullPath));
294
+ }
295
+ else if (entry.isFile() && /\.zip$/i.test(entry.name)) {
296
+ results.push(fullPath);
297
+ }
298
+ }
299
+ return results;
300
+ }
266
301
  getAllFiles(dir, includeSubdirs) {
267
302
  const files = [];
268
303
  const readDir = (currentDir, relativePath = '') => {
@@ -403,6 +438,11 @@ class ExtractArchive {
403
438
  else if (archiveType === 'rar') {
404
439
  await extractor.extractRar(archivePath, extractDir, password || undefined);
405
440
  }
441
+ // Recursively extract nested ZIP archives
442
+ const recursiveExtract = this.getNodeParameter('recursiveExtract', itemIndex);
443
+ if (recursiveExtract) {
444
+ await extractor.extractNestedZips(extractDir, password || undefined);
445
+ }
406
446
  // Get all extracted files
407
447
  let files = extractor.getAllFiles(extractDir, includeSubdirectories);
408
448
  // Apply file filter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beltar/n8n-nodes-extract-archive",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "n8n node to extract ZIP and RAR archive files. Supports binary data or file path input.",
5
5
  "keywords": [
6
6
  "n8n",