@hamak/filesystem-server-impl 0.4.19 → 0.5.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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * File Info Enricher Registry
3
+ *
4
+ * Default implementation of the enricher registry.
5
+ */
6
+ import { FileInfo } from '@hamak/shared-utils';
7
+ import { IFileInfoEnricher, IFileInfoEnricherRegistry, EnricherContext } from '@hamak/filesystem-server-spi';
8
+ /**
9
+ * Default implementation of the FileInfo enricher registry
10
+ */
11
+ export declare class FileInfoEnricherRegistry implements IFileInfoEnricherRegistry {
12
+ private enrichers;
13
+ /**
14
+ * Register an enricher
15
+ */
16
+ register(enricher: IFileInfoEnricher): void;
17
+ /**
18
+ * Unregister an enricher by its extension key
19
+ */
20
+ unregister(extensionKey: string): void;
21
+ /**
22
+ * Get all registered enrichers sorted by priority
23
+ */
24
+ getEnrichers(): IFileInfoEnricher[];
25
+ /**
26
+ * Apply all applicable enrichers to a FileInfo
27
+ */
28
+ applyEnrichers(fileInfo: FileInfo, context: EnricherContext): Promise<FileInfo>;
29
+ /**
30
+ * Apply all applicable enrichers to multiple FileInfo objects
31
+ */
32
+ applyEnrichersMany(fileInfos: FileInfo[], context: EnricherContext): Promise<FileInfo[]>;
33
+ }
34
+ /**
35
+ * Create a new enricher registry
36
+ */
37
+ export declare function createFileInfoEnricherRegistry(): IFileInfoEnricherRegistry;
38
+ //# sourceMappingURL=file-info-enricher-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-info-enricher-registry.d.ts","sourceRoot":"","sources":["../../src/enrichers/file-info-enricher-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,qBAAa,wBAAyB,YAAW,yBAAyB;IACxE,OAAO,CAAC,SAAS,CAA6C;IAE9D;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAI3C;;OAEG;IACH,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAItC;;OAEG;IACH,YAAY,IAAI,iBAAiB,EAAE;IAMnC;;OAEG;IACG,cAAc,CAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,QAAQ,CAAC;IAYpB;;OAEG;IACG,kBAAkB,CACtB,SAAS,EAAE,QAAQ,EAAE,EACrB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;CAyBvB;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,yBAAyB,CAE1E"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * File Info Enricher Registry
3
+ *
4
+ * Default implementation of the enricher registry.
5
+ */
6
+ /**
7
+ * Default implementation of the FileInfo enricher registry
8
+ */
9
+ export class FileInfoEnricherRegistry {
10
+ constructor() {
11
+ this.enrichers = new Map();
12
+ }
13
+ /**
14
+ * Register an enricher
15
+ */
16
+ register(enricher) {
17
+ this.enrichers.set(enricher.extensionKey, enricher);
18
+ }
19
+ /**
20
+ * Unregister an enricher by its extension key
21
+ */
22
+ unregister(extensionKey) {
23
+ this.enrichers.delete(extensionKey);
24
+ }
25
+ /**
26
+ * Get all registered enrichers sorted by priority
27
+ */
28
+ getEnrichers() {
29
+ return Array.from(this.enrichers.values()).sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
30
+ }
31
+ /**
32
+ * Apply all applicable enrichers to a FileInfo
33
+ */
34
+ async applyEnrichers(fileInfo, context) {
35
+ let result = fileInfo;
36
+ for (const enricher of this.getEnrichers()) {
37
+ if (enricher.shouldEnrich(context)) {
38
+ result = await enricher.enrich(result, context);
39
+ }
40
+ }
41
+ return result;
42
+ }
43
+ /**
44
+ * Apply all applicable enrichers to multiple FileInfo objects
45
+ */
46
+ async applyEnrichersMany(fileInfos, context) {
47
+ const applicableEnrichers = this.getEnrichers().filter((e) => e.shouldEnrich(context));
48
+ if (applicableEnrichers.length === 0) {
49
+ return fileInfos;
50
+ }
51
+ let result = fileInfos;
52
+ for (const enricher of applicableEnrichers) {
53
+ if (enricher.enrichMany) {
54
+ // Use batch enrichment if available
55
+ result = await enricher.enrichMany(result, context);
56
+ }
57
+ else {
58
+ // Fall back to individual enrichment
59
+ result = await Promise.all(result.map((fileInfo) => enricher.enrich(fileInfo, context)));
60
+ }
61
+ }
62
+ return result;
63
+ }
64
+ }
65
+ /**
66
+ * Create a new enricher registry
67
+ */
68
+ export function createFileInfoEnricherRegistry() {
69
+ return new FileInfoEnricherRegistry();
70
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * File Info Enricher Registry
4
+ *
5
+ * Default implementation of the enricher registry.
6
+ */
7
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createFileInfoEnricherRegistry = exports.FileInfoEnricherRegistry = void 0;
18
+ /**
19
+ * Default implementation of the FileInfo enricher registry
20
+ */
21
+ class FileInfoEnricherRegistry {
22
+ constructor() {
23
+ this.enrichers = new Map();
24
+ }
25
+ /**
26
+ * Register an enricher
27
+ */
28
+ register(enricher) {
29
+ this.enrichers.set(enricher.extensionKey, enricher);
30
+ }
31
+ /**
32
+ * Unregister an enricher by its extension key
33
+ */
34
+ unregister(extensionKey) {
35
+ this.enrichers.delete(extensionKey);
36
+ }
37
+ /**
38
+ * Get all registered enrichers sorted by priority
39
+ */
40
+ getEnrichers() {
41
+ return Array.from(this.enrichers.values()).sort((a, b) => { var _a, _b; return ((_a = a.priority) !== null && _a !== void 0 ? _a : 100) - ((_b = b.priority) !== null && _b !== void 0 ? _b : 100); });
42
+ }
43
+ /**
44
+ * Apply all applicable enrichers to a FileInfo
45
+ */
46
+ applyEnrichers(fileInfo, context) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ let result = fileInfo;
49
+ for (const enricher of this.getEnrichers()) {
50
+ if (enricher.shouldEnrich(context)) {
51
+ result = yield enricher.enrich(result, context);
52
+ }
53
+ }
54
+ return result;
55
+ });
56
+ }
57
+ /**
58
+ * Apply all applicable enrichers to multiple FileInfo objects
59
+ */
60
+ applyEnrichersMany(fileInfos, context) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const applicableEnrichers = this.getEnrichers().filter((e) => e.shouldEnrich(context));
63
+ if (applicableEnrichers.length === 0) {
64
+ return fileInfos;
65
+ }
66
+ let result = fileInfos;
67
+ for (const enricher of applicableEnrichers) {
68
+ if (enricher.enrichMany) {
69
+ // Use batch enrichment if available
70
+ result = yield enricher.enrichMany(result, context);
71
+ }
72
+ else {
73
+ // Fall back to individual enrichment
74
+ result = yield Promise.all(result.map((fileInfo) => enricher.enrich(fileInfo, context)));
75
+ }
76
+ }
77
+ return result;
78
+ });
79
+ }
80
+ }
81
+ exports.FileInfoEnricherRegistry = FileInfoEnricherRegistry;
82
+ /**
83
+ * Create a new enricher registry
84
+ */
85
+ function createFileInfoEnricherRegistry() {
86
+ return new FileInfoEnricherRegistry();
87
+ }
88
+ exports.createFileInfoEnricherRegistry = createFileInfoEnricherRegistry;
@@ -28,5 +28,7 @@ __exportStar(require("./routing/create-router"), exports);
28
28
  __exportStar(require("./routing/file-router"), exports);
29
29
  // Export middleware
30
30
  __exportStar(require("./middleware/workspace-validator"), exports);
31
+ // Export enrichers
32
+ __exportStar(require("./enrichers/file-info-enricher-registry"), exports);
31
33
  // Re-export API types for convenience
32
34
  __exportStar(require("@hamak/filesystem-server-api"), exports);
@@ -18,9 +18,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.FileRouter = void 0;
19
19
  const express_1 = require("express");
20
20
  class FileRouter {
21
- constructor(workspaceManager) {
21
+ constructor(workspaceManager, options) {
22
22
  this.router = (0, express_1.Router)();
23
23
  this.workspaceManager = workspaceManager;
24
+ this.enricherRegistry = options === null || options === void 0 ? void 0 : options.enricherRegistry;
24
25
  this.initializeRoutes();
25
26
  }
26
27
  initializeRoutes() {
@@ -36,13 +37,51 @@ class FileRouter {
36
37
  // Split path string into segments, filter out empty segments
37
38
  return pathString.split('/').filter(seg => seg.length > 0);
38
39
  }
40
+ /**
41
+ * Create enricher context from request
42
+ */
43
+ createEnricherContext(req, workspace, pathSegments, operation) {
44
+ // Note: resolvedPath would need workspace manager to expose path resolution
45
+ // For now, we pass an empty string and let enrichers handle it
46
+ return {
47
+ workspace,
48
+ pathSegments,
49
+ resolvedPath: '', // Will be populated by enrichers if needed
50
+ request: req,
51
+ operation,
52
+ };
53
+ }
54
+ /**
55
+ * Apply enrichers to a single FileInfo if registry is available
56
+ */
57
+ enrichFileInfo(fileInfo, context) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ if (!this.enricherRegistry) {
60
+ return fileInfo;
61
+ }
62
+ return this.enricherRegistry.applyEnrichers(fileInfo, context);
63
+ });
64
+ }
65
+ /**
66
+ * Apply enrichers to multiple FileInfo objects if registry is available
67
+ */
68
+ enrichFileInfoMany(fileInfos, context) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ if (!this.enricherRegistry) {
71
+ return fileInfos;
72
+ }
73
+ return this.enricherRegistry.applyEnrichersMany(fileInfos, context);
74
+ });
75
+ }
39
76
  listFiles(req, res) {
40
77
  return __awaiter(this, void 0, void 0, function* () {
41
78
  try {
42
79
  const { workspace } = req.params;
43
80
  const pathSegments = this.parsePath(req.params[0] || '');
44
81
  const files = yield this.workspaceManager.listFiles(workspace, pathSegments);
45
- res.json(files);
82
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'list');
83
+ const enrichedFiles = yield this.enrichFileInfoMany(files, context);
84
+ res.json(enrichedFiles);
46
85
  }
47
86
  catch (error) {
48
87
  res.status(500).json({ error: error.message });
@@ -55,7 +94,9 @@ class FileRouter {
55
94
  const { workspace } = req.params;
56
95
  const pathSegments = this.parsePath(req.params[0] || '');
57
96
  const dirInfo = yield this.workspaceManager.createDirectory(workspace, pathSegments);
58
- res.json(dirInfo);
97
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'mkdir');
98
+ const enrichedDirInfo = yield this.enrichFileInfo(dirInfo, context);
99
+ res.json(enrichedDirInfo);
59
100
  }
60
101
  catch (error) {
61
102
  res.status(500).json({ error: error.message });
@@ -68,7 +109,9 @@ class FileRouter {
68
109
  const { workspace } = req.params;
69
110
  const pathSegments = this.parsePath(req.params[0] || '');
70
111
  const fileInfo = yield this.workspaceManager.getFile(workspace, pathSegments);
71
- res.json(fileInfo);
112
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'get');
113
+ const enrichedFileInfo = yield this.enrichFileInfo(fileInfo, context);
114
+ res.json(enrichedFileInfo);
72
115
  }
73
116
  catch (error) {
74
117
  res.status(500).json({ error: error.message });
@@ -81,7 +124,9 @@ class FileRouter {
81
124
  const { workspace } = req.params;
82
125
  const pathSegments = this.parsePath(req.params[0] || '');
83
126
  const fileInfo = yield this.workspaceManager.readFile(workspace, pathSegments);
84
- res.json(fileInfo);
127
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'read');
128
+ const enrichedFileInfo = yield this.enrichFileInfo(fileInfo, context);
129
+ res.json(enrichedFileInfo);
85
130
  }
86
131
  catch (error) {
87
132
  res.status(500).json({ error: error.message });
@@ -95,7 +140,9 @@ class FileRouter {
95
140
  const pathSegments = this.parsePath(req.params[0] || '');
96
141
  const { content } = req.body;
97
142
  const fileInfo = yield this.workspaceManager.writeFile(workspace, pathSegments, content);
98
- res.json(fileInfo);
143
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'write');
144
+ const enrichedFileInfo = yield this.enrichFileInfo(fileInfo, context);
145
+ res.json(enrichedFileInfo);
99
146
  }
100
147
  catch (error) {
101
148
  res.status(500).json({ error: error.message });
@@ -108,7 +155,9 @@ class FileRouter {
108
155
  const { workspace } = req.params;
109
156
  const pathSegments = this.parsePath(req.params[0] || '');
110
157
  const fileInfo = yield this.workspaceManager.deleteFile(workspace, pathSegments);
111
- res.json(fileInfo);
158
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'delete');
159
+ const enrichedFileInfo = yield this.enrichFileInfo(fileInfo, context);
160
+ res.json(enrichedFileInfo);
112
161
  }
113
162
  catch (error) {
114
163
  res.status(500).json({ error: error.message });
package/dist/index.d.ts CHANGED
@@ -8,5 +8,6 @@ export * from './services/workspace-manager';
8
8
  export * from './routing/create-router';
9
9
  export * from './routing/file-router';
10
10
  export * from './middleware/workspace-validator';
11
+ export * from './enrichers/file-info-enricher-registry';
11
12
  export * from '@hamak/filesystem-server-api';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,mCAAmC,CAAC;AAGlD,cAAc,8BAA8B,CAAC;AAG7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,mCAAmC,CAAC;AAGlD,cAAc,8BAA8B,CAAC;AAG7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,yCAAyC,CAAC;AAGxD,cAAc,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -12,5 +12,7 @@ export * from './routing/create-router';
12
12
  export * from './routing/file-router';
13
13
  // Export middleware
14
14
  export * from './middleware/workspace-validator';
15
+ // Export enrichers
16
+ export * from './enrichers/file-info-enricher-registry';
15
17
  // Re-export API types for convenience
16
18
  export * from '@hamak/filesystem-server-api';
@@ -6,12 +6,32 @@
6
6
  */
7
7
  import { Router } from 'express';
8
8
  import { IWorkspaceManager } from '@hamak/filesystem-server-api';
9
+ import { IFileInfoEnricherRegistry } from '@hamak/filesystem-server-spi';
10
+ export interface FileRouterOptions {
11
+ /**
12
+ * Optional enricher registry for extending FileInfo responses
13
+ */
14
+ enricherRegistry?: IFileInfoEnricherRegistry;
15
+ }
9
16
  export declare class FileRouter {
10
17
  router: Router;
11
18
  private workspaceManager;
12
- constructor(workspaceManager: IWorkspaceManager);
19
+ private enricherRegistry?;
20
+ constructor(workspaceManager: IWorkspaceManager, options?: FileRouterOptions);
13
21
  private initializeRoutes;
14
22
  private parsePath;
23
+ /**
24
+ * Create enricher context from request
25
+ */
26
+ private createEnricherContext;
27
+ /**
28
+ * Apply enrichers to a single FileInfo if registry is available
29
+ */
30
+ private enrichFileInfo;
31
+ /**
32
+ * Apply enrichers to multiple FileInfo objects if registry is available
33
+ */
34
+ private enrichFileInfoMany;
15
35
  private listFiles;
16
36
  private createDirectory;
17
37
  private getFile;
@@ -1 +1 @@
1
- {"version":3,"file":"file-router.d.ts","sourceRoot":"","sources":["../../src/routing/file-router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,qBAAa,UAAU;IACd,MAAM,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,gBAAgB,CAAoB;gBAEhC,gBAAgB,EAAE,iBAAiB;IAM/C,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,SAAS;YAKH,SAAS;YAWT,eAAe;YAWf,OAAO;YAWP,QAAQ;YAWR,SAAS;YAYT,UAAU;CAUzB"}
1
+ {"version":3,"file":"file-router.d.ts","sourceRoot":"","sources":["../../src/routing/file-router.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAmB,MAAM,8BAA8B,CAAC;AAG1F,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;CAC9C;AAED,qBAAa,UAAU;IACd,MAAM,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,gBAAgB,CAAC,CAA4B;gBAEzC,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,iBAAiB;IAO5E,OAAO,CAAC,gBAAgB;IAUxB,OAAO,CAAC,SAAS;IAKjB;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;OAEG;YACW,cAAc;IAU5B;;OAEG;YACW,kBAAkB;YAUlB,SAAS;YAaT,eAAe;YAaf,OAAO;YAaP,QAAQ;YAaR,SAAS;YAcT,UAAU;CAYzB"}
@@ -6,9 +6,10 @@
6
6
  */
7
7
  import { Router } from 'express';
8
8
  export class FileRouter {
9
- constructor(workspaceManager) {
9
+ constructor(workspaceManager, options) {
10
10
  this.router = Router();
11
11
  this.workspaceManager = workspaceManager;
12
+ this.enricherRegistry = options?.enricherRegistry;
12
13
  this.initializeRoutes();
13
14
  }
14
15
  initializeRoutes() {
@@ -24,12 +25,46 @@ export class FileRouter {
24
25
  // Split path string into segments, filter out empty segments
25
26
  return pathString.split('/').filter(seg => seg.length > 0);
26
27
  }
28
+ /**
29
+ * Create enricher context from request
30
+ */
31
+ createEnricherContext(req, workspace, pathSegments, operation) {
32
+ // Note: resolvedPath would need workspace manager to expose path resolution
33
+ // For now, we pass an empty string and let enrichers handle it
34
+ return {
35
+ workspace,
36
+ pathSegments,
37
+ resolvedPath: '', // Will be populated by enrichers if needed
38
+ request: req,
39
+ operation,
40
+ };
41
+ }
42
+ /**
43
+ * Apply enrichers to a single FileInfo if registry is available
44
+ */
45
+ async enrichFileInfo(fileInfo, context) {
46
+ if (!this.enricherRegistry) {
47
+ return fileInfo;
48
+ }
49
+ return this.enricherRegistry.applyEnrichers(fileInfo, context);
50
+ }
51
+ /**
52
+ * Apply enrichers to multiple FileInfo objects if registry is available
53
+ */
54
+ async enrichFileInfoMany(fileInfos, context) {
55
+ if (!this.enricherRegistry) {
56
+ return fileInfos;
57
+ }
58
+ return this.enricherRegistry.applyEnrichersMany(fileInfos, context);
59
+ }
27
60
  async listFiles(req, res) {
28
61
  try {
29
62
  const { workspace } = req.params;
30
63
  const pathSegments = this.parsePath(req.params[0] || '');
31
64
  const files = await this.workspaceManager.listFiles(workspace, pathSegments);
32
- res.json(files);
65
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'list');
66
+ const enrichedFiles = await this.enrichFileInfoMany(files, context);
67
+ res.json(enrichedFiles);
33
68
  }
34
69
  catch (error) {
35
70
  res.status(500).json({ error: error.message });
@@ -40,7 +75,9 @@ export class FileRouter {
40
75
  const { workspace } = req.params;
41
76
  const pathSegments = this.parsePath(req.params[0] || '');
42
77
  const dirInfo = await this.workspaceManager.createDirectory(workspace, pathSegments);
43
- res.json(dirInfo);
78
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'mkdir');
79
+ const enrichedDirInfo = await this.enrichFileInfo(dirInfo, context);
80
+ res.json(enrichedDirInfo);
44
81
  }
45
82
  catch (error) {
46
83
  res.status(500).json({ error: error.message });
@@ -51,7 +88,9 @@ export class FileRouter {
51
88
  const { workspace } = req.params;
52
89
  const pathSegments = this.parsePath(req.params[0] || '');
53
90
  const fileInfo = await this.workspaceManager.getFile(workspace, pathSegments);
54
- res.json(fileInfo);
91
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'get');
92
+ const enrichedFileInfo = await this.enrichFileInfo(fileInfo, context);
93
+ res.json(enrichedFileInfo);
55
94
  }
56
95
  catch (error) {
57
96
  res.status(500).json({ error: error.message });
@@ -62,7 +101,9 @@ export class FileRouter {
62
101
  const { workspace } = req.params;
63
102
  const pathSegments = this.parsePath(req.params[0] || '');
64
103
  const fileInfo = await this.workspaceManager.readFile(workspace, pathSegments);
65
- res.json(fileInfo);
104
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'read');
105
+ const enrichedFileInfo = await this.enrichFileInfo(fileInfo, context);
106
+ res.json(enrichedFileInfo);
66
107
  }
67
108
  catch (error) {
68
109
  res.status(500).json({ error: error.message });
@@ -74,7 +115,9 @@ export class FileRouter {
74
115
  const pathSegments = this.parsePath(req.params[0] || '');
75
116
  const { content } = req.body;
76
117
  const fileInfo = await this.workspaceManager.writeFile(workspace, pathSegments, content);
77
- res.json(fileInfo);
118
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'write');
119
+ const enrichedFileInfo = await this.enrichFileInfo(fileInfo, context);
120
+ res.json(enrichedFileInfo);
78
121
  }
79
122
  catch (error) {
80
123
  res.status(500).json({ error: error.message });
@@ -85,7 +128,9 @@ export class FileRouter {
85
128
  const { workspace } = req.params;
86
129
  const pathSegments = this.parsePath(req.params[0] || '');
87
130
  const fileInfo = await this.workspaceManager.deleteFile(workspace, pathSegments);
88
- res.json(fileInfo);
131
+ const context = this.createEnricherContext(req, workspace, pathSegments, 'delete');
132
+ const enrichedFileInfo = await this.enrichFileInfo(fileInfo, context);
133
+ res.json(enrichedFileInfo);
89
134
  }
90
135
  catch (error) {
91
136
  res.status(500).json({ error: error.message });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hamak/filesystem-server-impl",
3
- "version": "0.4.19",
3
+ "version": "0.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "FileSystem Server Implementation - Backend filesystem server with Express routes",