@qodalis/cli-files 2.0.0-beta.12 → 2.0.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qodalis/cli-files",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.13",
4
4
  "description": "@qodalis/cli extension for Linux file management commands with in-memory filesystem.",
5
5
  "author": "Nicolae Lupei, Qodalis Solutions",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "umd": "./umd/index.global.js",
24
24
  "unpkg": "./umd/index.global.js",
25
25
  "dependencies": {
26
- "@qodalis/cli-core": "2.0.0-beta.12"
26
+ "@qodalis/cli-core": "2.0.0-beta.13"
27
27
  },
28
28
  "sideEffects": false,
29
29
  "main": "./public-api.js",
package/public-api.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _qodalis_cli_core from '@qodalis/cli-core';
2
- import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliConfigurableModule } from '@qodalis/cli-core';
2
+ import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, CliHeadersProvider, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliConfigurableModule } from '@qodalis/cli-core';
3
3
  import { Subscription } from 'rxjs';
4
4
 
5
5
  /**
@@ -884,6 +884,8 @@ declare class IndexedDbFileSystemService implements IFileSystemService {
884
884
  interface ServerFileSystemOptions {
885
885
  /** Base URL of the CLI server, e.g. 'http://localhost:8047' */
886
886
  baseUrl: string;
887
+ /** Custom headers sent with every request (e.g. auth tokens) */
888
+ headers?: CliHeadersProvider;
887
889
  }
888
890
  /**
889
891
  * IFileSystemService implementation that delegates operations to a CLI server's
@@ -902,6 +904,7 @@ declare class ServerFileSystemService implements IFileSystemService {
902
904
  private currentUid;
903
905
  private currentGroups;
904
906
  private readonly baseUrl;
907
+ private readonly headersProvider;
905
908
  constructor(options: ServerFileSystemOptions);
906
909
  setCurrentUser(uid: string, groups: string[]): void;
907
910
  private getDefaultOwnership;
package/public-api.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _qodalis_cli_core from '@qodalis/cli-core';
2
- import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliConfigurableModule } from '@qodalis/cli-core';
2
+ import { ICliOwnership, ICliCommandProcessor, CliProcessCommand, ICliExecutionContext, CliHeadersProvider, ICliFileTransferService, ICliFileEntry, ICliCompletionProvider, ICliCompletionContext, ICliConfigurableModule } from '@qodalis/cli-core';
3
3
  import { Subscription } from 'rxjs';
4
4
 
5
5
  /**
@@ -884,6 +884,8 @@ declare class IndexedDbFileSystemService implements IFileSystemService {
884
884
  interface ServerFileSystemOptions {
885
885
  /** Base URL of the CLI server, e.g. 'http://localhost:8047' */
886
886
  baseUrl: string;
887
+ /** Custom headers sent with every request (e.g. auth tokens) */
888
+ headers?: CliHeadersProvider;
887
889
  }
888
890
  /**
889
891
  * IFileSystemService implementation that delegates operations to a CLI server's
@@ -902,6 +904,7 @@ declare class ServerFileSystemService implements IFileSystemService {
902
904
  private currentUid;
903
905
  private currentGroups;
904
906
  private readonly baseUrl;
907
+ private readonly headersProvider;
905
908
  constructor(options: ServerFileSystemOptions);
906
909
  setCurrentUser(uid: string, groups: string[]): void;
907
910
  private getDefaultOwnership;
package/public-api.js CHANGED
@@ -6,7 +6,7 @@ var cliCore = require('@qodalis/cli-core');
6
6
  var IFileSystemService_TOKEN = "cli-file-system-service";
7
7
 
8
8
  // src/lib/version.ts
9
- var LIBRARY_VERSION = "2.0.0-beta.12";
9
+ var LIBRARY_VERSION = "2.0.0-beta.13";
10
10
  var API_VERSION = 2;
11
11
 
12
12
  // src/lib/processors/cli-ls-command-processor.ts
@@ -36,7 +36,7 @@ var CliLsCommandProcessor = class {
36
36
  ];
37
37
  }
38
38
  async processCommand(command, context) {
39
- const fs = context.services.get(
39
+ const fs = context.services.getRequired(
40
40
  IFileSystemService_TOKEN
41
41
  );
42
42
  const targetPath = command.value || fs.getCurrentDirectory();
@@ -107,7 +107,7 @@ var CliCdCommandProcessor = class {
107
107
  this.metadata = { icon: "\u{1F4C1}", module: "file management" };
108
108
  }
109
109
  async processCommand(command, context) {
110
- const fs = context.services.get(
110
+ const fs = context.services.getRequired(
111
111
  IFileSystemService_TOKEN
112
112
  );
113
113
  const target = command.value || "~";
@@ -128,7 +128,7 @@ var CliPwdCommandProcessor = class {
128
128
  this.metadata = { icon: "\u{1F4C2}", module: "file management" };
129
129
  }
130
130
  async processCommand(command, context) {
131
- const fs = context.services.get(
131
+ const fs = context.services.getRequired(
132
132
  IFileSystemService_TOKEN
133
133
  );
134
134
  context.writer.writeln(fs.getCurrentDirectory());
@@ -154,7 +154,7 @@ var CliMkdirCommandProcessor = class {
154
154
  ];
155
155
  }
156
156
  async processCommand(command, context) {
157
- const fs = context.services.get(
157
+ const fs = context.services.getRequired(
158
158
  IFileSystemService_TOKEN
159
159
  );
160
160
  const path = command.value;
@@ -182,7 +182,7 @@ var CliRmdirCommandProcessor = class {
182
182
  this.metadata = { icon: "\u{1F5D1}", module: "file management" };
183
183
  }
184
184
  async processCommand(command, context) {
185
- const fs = context.services.get(
185
+ const fs = context.services.getRequired(
186
186
  IFileSystemService_TOKEN
187
187
  );
188
188
  const path = command.value;
@@ -226,7 +226,7 @@ var CliTouchCommandProcessor = class {
226
226
  this.metadata = { icon: "\u{1F4C4}", module: "file management" };
227
227
  }
228
228
  async processCommand(command, context) {
229
- const fs = context.services.get(
229
+ const fs = context.services.getRequired(
230
230
  IFileSystemService_TOKEN
231
231
  );
232
232
  const path = command.value;
@@ -253,7 +253,7 @@ var CliCatCommandProcessor = class {
253
253
  this.metadata = { icon: "\u{1F4D6}", module: "file management" };
254
254
  }
255
255
  async processCommand(command, context) {
256
- const fs = context.services.get(
256
+ const fs = context.services.getRequired(
257
257
  IFileSystemService_TOKEN
258
258
  );
259
259
  const path = command.value;
@@ -292,7 +292,7 @@ var CliEchoCommandProcessor = class {
292
292
  }
293
293
  return;
294
294
  }
295
- const fs = context.services.get(
295
+ const fs = context.services.getRequired(
296
296
  IFileSystemService_TOKEN
297
297
  );
298
298
  let text;
@@ -364,7 +364,7 @@ var CliRmCommandProcessor = class {
364
364
  ];
365
365
  }
366
366
  async processCommand(command, context) {
367
- const fs = context.services.get(
367
+ const fs = context.services.getRequired(
368
368
  IFileSystemService_TOKEN
369
369
  );
370
370
  const path = command.value;
@@ -413,7 +413,7 @@ var CliCpCommandProcessor = class {
413
413
  ];
414
414
  }
415
415
  async processCommand(command, context) {
416
- const fs = context.services.get(
416
+ const fs = context.services.getRequired(
417
417
  IFileSystemService_TOKEN
418
418
  );
419
419
  const recursive = command.args["recursive"] || command.args["r"] || command.args["R"];
@@ -449,7 +449,7 @@ var CliMvCommandProcessor = class {
449
449
  this.metadata = { icon: "\u{1F4E6}", module: "file management" };
450
450
  }
451
451
  async processCommand(command, context) {
452
- const fs = context.services.get(
452
+ const fs = context.services.getRequired(
453
453
  IFileSystemService_TOKEN
454
454
  );
455
455
  const parts = this.parseArgs(command);
@@ -491,7 +491,7 @@ var CliTreeCommandProcessor = class {
491
491
  ];
492
492
  }
493
493
  async processCommand(command, context) {
494
- const fs = context.services.get(
494
+ const fs = context.services.getRequired(
495
495
  IFileSystemService_TOKEN
496
496
  );
497
497
  const targetPath = command.value || fs.getCurrentDirectory();
@@ -584,7 +584,7 @@ var CliHeadCommandProcessor = class {
584
584
  ];
585
585
  }
586
586
  async processCommand(command, context) {
587
- const fs = context.services.get(
587
+ const fs = context.services.getRequired(
588
588
  IFileSystemService_TOKEN
589
589
  );
590
590
  const count = parseInt(
@@ -649,7 +649,7 @@ var CliTailCommandProcessor = class {
649
649
  ];
650
650
  }
651
651
  async processCommand(command, context) {
652
- const fs = context.services.get(
652
+ const fs = context.services.getRequired(
653
653
  IFileSystemService_TOKEN
654
654
  );
655
655
  const count = parseInt(
@@ -728,7 +728,7 @@ var CliWcCommandProcessor = class {
728
728
  ];
729
729
  }
730
730
  async processCommand(command, context) {
731
- const fs = context.services.get(
731
+ const fs = context.services.getRequired(
732
732
  IFileSystemService_TOKEN
733
733
  );
734
734
  const showLines = command.args["lines"] || command.args["l"] || false;
@@ -822,7 +822,7 @@ var CliFindCommandProcessor = class {
822
822
  ];
823
823
  }
824
824
  async processCommand(command, context) {
825
- const fs = context.services.get(
825
+ const fs = context.services.getRequired(
826
826
  IFileSystemService_TOKEN
827
827
  );
828
828
  const searchPath = this.parseSearchPath(command) || fs.getCurrentDirectory();
@@ -957,7 +957,7 @@ var CliGrepCommandProcessor = class {
957
957
  ];
958
958
  }
959
959
  async processCommand(command, context) {
960
- const fs = context.services.get(
960
+ const fs = context.services.getRequired(
961
961
  IFileSystemService_TOKEN
962
962
  );
963
963
  const ignoreCase = command.args["ignore-case"] || command.args["i"] || false;
@@ -1127,7 +1127,7 @@ var CliTacCommandProcessor = class {
1127
1127
  this.metadata = { icon: "\u{1F504}", module: "file management" };
1128
1128
  }
1129
1129
  async processCommand(command, context) {
1130
- const fs = context.services.get(
1130
+ const fs = context.services.getRequired(
1131
1131
  IFileSystemService_TOKEN
1132
1132
  );
1133
1133
  const paths = this.parsePaths(command);
@@ -1299,7 +1299,7 @@ var CliSortCommandProcessor = class {
1299
1299
  ];
1300
1300
  }
1301
1301
  async processCommand(command, context) {
1302
- const fs = context.services.get(
1302
+ const fs = context.services.getRequired(
1303
1303
  IFileSystemService_TOKEN
1304
1304
  );
1305
1305
  const reverse = !!command.args["r"] || !!command.args["reverse"];
@@ -1452,7 +1452,7 @@ var CliUniqCommandProcessor = class {
1452
1452
  ];
1453
1453
  }
1454
1454
  async processCommand(command, context) {
1455
- const fs = context.services.get(
1455
+ const fs = context.services.getRequired(
1456
1456
  IFileSystemService_TOKEN
1457
1457
  );
1458
1458
  const showCount = !!command.args["c"] || !!command.args["count"];
@@ -1583,7 +1583,7 @@ var CliCutCommandProcessor = class {
1583
1583
  ];
1584
1584
  }
1585
1585
  async processCommand(command, context) {
1586
- const fs = context.services.get(
1586
+ const fs = context.services.getRequired(
1587
1587
  IFileSystemService_TOKEN
1588
1588
  );
1589
1589
  const delimiter = command.args["d"] || command.args["delimiter"] || " ";
@@ -1733,7 +1733,7 @@ var CliPasteCommandProcessor = class {
1733
1733
  ];
1734
1734
  }
1735
1735
  async processCommand(command, context) {
1736
- const fs = context.services.get(
1736
+ const fs = context.services.getRequired(
1737
1737
  IFileSystemService_TOKEN
1738
1738
  );
1739
1739
  const delimiter = command.args["d"] || command.args["delimiters"] || " ";
@@ -1900,7 +1900,7 @@ var CliTrCommandProcessor = class {
1900
1900
  ];
1901
1901
  }
1902
1902
  async processCommand(command, context) {
1903
- const fs = context.services.get(
1903
+ const fs = context.services.getRequired(
1904
1904
  IFileSystemService_TOKEN
1905
1905
  );
1906
1906
  const raw = command.value || "";
@@ -2055,7 +2055,7 @@ var CliStatCommandProcessor = class {
2055
2055
  this.parameters = [];
2056
2056
  }
2057
2057
  async processCommand(command, context) {
2058
- const fs = context.services.get(
2058
+ const fs = context.services.getRequired(
2059
2059
  IFileSystemService_TOKEN
2060
2060
  );
2061
2061
  const paths = this.parsePaths(command);
@@ -2108,7 +2108,7 @@ var CliChmodCommandProcessor = class {
2108
2108
  ];
2109
2109
  }
2110
2110
  async processCommand(command, context) {
2111
- const fs = context.services.get(
2111
+ const fs = context.services.getRequired(
2112
2112
  IFileSystemService_TOKEN
2113
2113
  );
2114
2114
  const { recursive, mode, paths } = this.parseArgs(command);
@@ -2228,7 +2228,7 @@ var CliChownCommandProcessor = class {
2228
2228
  ];
2229
2229
  }
2230
2230
  async processCommand(command, context) {
2231
- const fs = context.services.get(
2231
+ const fs = context.services.getRequired(
2232
2232
  IFileSystemService_TOKEN
2233
2233
  );
2234
2234
  const { recursive, ownerSpec, paths } = this.parseArgs(command);
@@ -2323,7 +2323,7 @@ var CliDuCommandProcessor = class {
2323
2323
  ];
2324
2324
  }
2325
2325
  async processCommand(command, context) {
2326
- const fs = context.services.get(
2326
+ const fs = context.services.getRequired(
2327
2327
  IFileSystemService_TOKEN
2328
2328
  );
2329
2329
  const { humanReadable, summaryOnly, maxDepth, paths } = this.parseArgs(command);
@@ -2420,7 +2420,7 @@ var CliLnCommandProcessor = class {
2420
2420
  ];
2421
2421
  }
2422
2422
  async processCommand(command, context) {
2423
- const fs = context.services.get(
2423
+ const fs = context.services.getRequired(
2424
2424
  IFileSystemService_TOKEN
2425
2425
  );
2426
2426
  const { symbolic, target, linkName } = this.parseArgs(command);
@@ -2494,7 +2494,7 @@ var CliSedCommandProcessor = class {
2494
2494
  ];
2495
2495
  }
2496
2496
  async processCommand(command, context) {
2497
- const fs = context.services.get(
2497
+ const fs = context.services.getRequired(
2498
2498
  IFileSystemService_TOKEN
2499
2499
  );
2500
2500
  const { inPlace, suppress, expressions, filePath } = this.parseRawCommand(command);
@@ -2837,7 +2837,7 @@ var CliAwkCommandProcessor = class {
2837
2837
  ];
2838
2838
  }
2839
2839
  async processCommand(command, context) {
2840
- const fs = context.services.get(
2840
+ const fs = context.services.getRequired(
2841
2841
  IFileSystemService_TOKEN
2842
2842
  );
2843
2843
  const { program, filePath, fieldSep } = this.parseArgs(command);
@@ -3313,7 +3313,7 @@ var CliDiffCommandProcessor = class {
3313
3313
  ];
3314
3314
  }
3315
3315
  async processCommand(command, context) {
3316
- const fs = context.services.get(
3316
+ const fs = context.services.getRequired(
3317
3317
  IFileSystemService_TOKEN
3318
3318
  );
3319
3319
  const unified = command.args["unified"] || command.args["u"] || false;
@@ -3499,7 +3499,7 @@ var CliTeeCommandProcessor = class {
3499
3499
  ];
3500
3500
  }
3501
3501
  async processCommand(command, context) {
3502
- const fs = context.services.get(
3502
+ const fs = context.services.getRequired(
3503
3503
  IFileSystemService_TOKEN
3504
3504
  );
3505
3505
  const append = command.args["append"] || command.args["a"] || false;
@@ -3593,7 +3593,7 @@ var CliXargsCommandProcessor = class {
3593
3593
  ];
3594
3594
  }
3595
3595
  async processCommand(command, context) {
3596
- const fs = context.services.get(
3596
+ const fs = context.services.getRequired(
3597
3597
  IFileSystemService_TOKEN
3598
3598
  );
3599
3599
  const replaceStr = command.args["replace"] || command.args["I"] || null;
@@ -3706,7 +3706,7 @@ var CliShCommandProcessor = class {
3706
3706
  ];
3707
3707
  }
3708
3708
  async processCommand(command, context) {
3709
- const fs = context.services.get(
3709
+ const fs = context.services.getRequired(
3710
3710
  IFileSystemService_TOKEN
3711
3711
  );
3712
3712
  let filePath = (command.value || "").trim();
@@ -4332,8 +4332,6 @@ var IndexedDbFileSystemService = class {
4332
4332
  });
4333
4333
  }
4334
4334
  };
4335
-
4336
- // src/lib/services/server-file-system.service.ts
4337
4335
  var DEFAULT_HOME2 = "/home/user";
4338
4336
  function createSeedFileSystem2() {
4339
4337
  const now = Date.now();
@@ -4383,6 +4381,7 @@ var ServerFileSystemService = class {
4383
4381
  this.currentUid = null;
4384
4382
  this.currentGroups = [];
4385
4383
  this.baseUrl = options.baseUrl.replace(/\/+$/, "");
4384
+ this.headersProvider = options.headers;
4386
4385
  }
4387
4386
  // --- User context ---
4388
4387
  setCurrentUser(uid, groups) {
@@ -4790,7 +4789,14 @@ var ServerFileSystemService = class {
4790
4789
  // --- Private: server communication ---
4791
4790
  async serverFetch(endpoint, options) {
4792
4791
  const url = `${this.baseUrl}/api/qcli/fs${endpoint}`;
4793
- const response = await fetch(url, options);
4792
+ const mergedHeaders = {
4793
+ ...cliCore.resolveHeaders(this.headersProvider),
4794
+ ...options?.headers ?? {}
4795
+ };
4796
+ const response = await fetch(url, {
4797
+ ...options,
4798
+ headers: mergedHeaders
4799
+ });
4794
4800
  if (!response.ok) {
4795
4801
  const body = await response.text();
4796
4802
  throw new Error(
@@ -5059,10 +5065,10 @@ var CliUploadCommandProcessor = class {
5059
5065
  ];
5060
5066
  }
5061
5067
  async processCommand(command, context) {
5062
- const fs = context.services.get(
5068
+ const fs = context.services.getRequired(
5063
5069
  IFileSystemService_TOKEN
5064
5070
  );
5065
- const fileService = context.services.get(
5071
+ const fileService = context.services.getRequired(
5066
5072
  cliCore.ICliFileTransferService_TOKEN
5067
5073
  );
5068
5074
  if (!fileService) {
@@ -5072,7 +5078,7 @@ var CliUploadCommandProcessor = class {
5072
5078
  const accept = command.args?.["accept"];
5073
5079
  const destPath = command.value?.trim() || void 0;
5074
5080
  context.spinner?.show("Waiting for file selection...");
5075
- context.setStatusText("Waiting for file selection");
5081
+ context.notifier.info("Waiting for file selection");
5076
5082
  const picked = await fileService.uploadFromBrowser(accept);
5077
5083
  if (!picked) {
5078
5084
  context.spinner?.hide();
@@ -5085,7 +5091,7 @@ var CliUploadCommandProcessor = class {
5085
5091
  filename.startsWith("/") ? filename : cwd + "/" + filename
5086
5092
  );
5087
5093
  context.spinner?.show(`Saving "${picked.name}" (${picked.content.length} bytes)...`);
5088
- context.setStatusText(`Saving ${picked.name}`);
5094
+ context.notifier.info(`Saving ${picked.name}`);
5089
5095
  try {
5090
5096
  fs.writeFile(resolved, picked.content);
5091
5097
  await fs.persist();
@@ -5184,7 +5190,7 @@ var filesModule = {
5184
5190
  return { ...this, config };
5185
5191
  },
5186
5192
  async onInit(context) {
5187
- const fs = context.services.get(
5193
+ const fs = context.services.getRequired(
5188
5194
  IFileSystemService_TOKEN
5189
5195
  );
5190
5196
  await fs.initialize();
@@ -5195,7 +5201,7 @@ var filesModule = {
5195
5201
  }
5196
5202
  let dragDrop;
5197
5203
  try {
5198
- dragDrop = context.services.get(cliCore.ICliDragDropService_TOKEN);
5204
+ dragDrop = context.services.getRequired(cliCore.ICliDragDropService_TOKEN);
5199
5205
  } catch {
5200
5206
  }
5201
5207
  if (dragDrop) {