@hamak/filesystem-server-api 0.4.8

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,26 @@
1
+ /**
2
+ * FileSystem Service Interface
3
+ *
4
+ * Main service interface for filesystem server operations
5
+ */
6
+ import { Router } from 'express';
7
+ import { IWorkspaceManager } from './IWorkspaceManager';
8
+ export interface IFileSystemService {
9
+ /**
10
+ * Get the workspace manager instance
11
+ */
12
+ getWorkspaceManager(): IWorkspaceManager;
13
+ /**
14
+ * Get the Express router for mounting in application
15
+ */
16
+ getRouter(): Router;
17
+ /**
18
+ * Initialize the service
19
+ */
20
+ initialize(): Promise<void>;
21
+ /**
22
+ * Cleanup and shutdown
23
+ */
24
+ shutdown(): Promise<void>;
25
+ }
26
+ //# sourceMappingURL=IFileSystemService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IFileSystemService.d.ts","sourceRoot":"","sources":["../../src/api/IFileSystemService.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,mBAAmB,IAAI,iBAAiB,CAAC;IAEzC;;OAEG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * FileSystem Service Interface
3
+ *
4
+ * Main service interface for filesystem server operations
5
+ */
6
+ export {};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Workspace Manager Interface
3
+ *
4
+ * Provides filesystem operations for a workspace (directory-based storage)
5
+ */
6
+ import { FileInfo } from '@hamak/shared-utils';
7
+ export interface IWorkspaceManager {
8
+ /**
9
+ * List files and directories at the given path
10
+ * @param workspace - Workspace ID
11
+ * @param path - Path segments relative to workspace root
12
+ * @returns Array of FileInfo objects
13
+ */
14
+ listFiles(workspace: string, path: string[]): Promise<FileInfo[]>;
15
+ /**
16
+ * Read file metadata and content
17
+ * @param workspace - Workspace ID
18
+ * @param path - Path segments to the file
19
+ * @returns FileInfo with content
20
+ */
21
+ readFile(workspace: string, path: string[]): Promise<FileInfo>;
22
+ /**
23
+ * Write content to a file
24
+ * @param workspace - Workspace ID
25
+ * @param path - Path segments to the file
26
+ * @param content - File content as string
27
+ * @returns FileInfo of the written file
28
+ */
29
+ writeFile(workspace: string, path: string[], content: string): Promise<FileInfo>;
30
+ /**
31
+ * Delete a file or directory
32
+ * @param workspace - Workspace ID
33
+ * @param path - Path segments to the file/directory
34
+ * @returns FileInfo of the deleted item
35
+ */
36
+ deleteFile(workspace: string, path: string[]): Promise<FileInfo>;
37
+ /**
38
+ * Create a directory
39
+ * @param workspace - Workspace ID
40
+ * @param path - Path segments to the new directory
41
+ * @returns FileInfo of the created directory
42
+ */
43
+ createDirectory(workspace: string, path: string[]): Promise<FileInfo>;
44
+ /**
45
+ * Get file metadata without content
46
+ * @param workspace - Workspace ID
47
+ * @param path - Path segments to the file
48
+ * @returns FileInfo without content
49
+ */
50
+ getFile(workspace: string, path: string[]): Promise<FileInfo>;
51
+ }
52
+ //# sourceMappingURL=IWorkspaceManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IWorkspaceManager.d.ts","sourceRoot":"","sources":["../../src/api/IWorkspaceManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAElE;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE/D;;;;;;OAMG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjF;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjE;;;;;OAKG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEtE;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/D"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Workspace Manager Interface
3
+ *
4
+ * Provides filesystem operations for a workspace (directory-based storage)
5
+ */
6
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Dependency Injection Tokens
3
+ *
4
+ * Tokens for registering and resolving services in the DI container
5
+ */
6
+ /**
7
+ * Token for FileSystemServerConfig
8
+ */
9
+ export declare const FILESYSTEM_SERVER_CONFIG_TOKEN: unique symbol;
10
+ /**
11
+ * Token for WorkspaceManager service
12
+ */
13
+ export declare const WORKSPACE_MANAGER_TOKEN: unique symbol;
14
+ /**
15
+ * Token for FileRouter (Express router)
16
+ */
17
+ export declare const FILE_ROUTER_TOKEN: unique symbol;
18
+ /**
19
+ * Token for main FileSystemService
20
+ */
21
+ export declare const FILESYSTEM_SERVICE_TOKEN: unique symbol;
22
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/api/tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,8BAA8B,eAAmC,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,uBAAuB,eAA6B,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,iBAAiB,eAAuB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,wBAAwB,eAA8B,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Dependency Injection Tokens
3
+ *
4
+ * Tokens for registering and resolving services in the DI container
5
+ */
6
+ /**
7
+ * Token for FileSystemServerConfig
8
+ */
9
+ export const FILESYSTEM_SERVER_CONFIG_TOKEN = Symbol('FileSystemServerConfig');
10
+ /**
11
+ * Token for WorkspaceManager service
12
+ */
13
+ export const WORKSPACE_MANAGER_TOKEN = Symbol('WorkspaceManager');
14
+ /**
15
+ * Token for FileRouter (Express router)
16
+ */
17
+ export const FILE_ROUTER_TOKEN = Symbol('FileRouter');
18
+ /**
19
+ * Token for main FileSystemService
20
+ */
21
+ export const FILESYSTEM_SERVICE_TOKEN = Symbol('FileSystemService');
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * FileSystem Service Interface
4
+ *
5
+ * Main service interface for filesystem server operations
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Workspace Manager Interface
4
+ *
5
+ * Provides filesystem operations for a workspace (directory-based storage)
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * Dependency Injection Tokens
4
+ *
5
+ * Tokens for registering and resolving services in the DI container
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.FILESYSTEM_SERVICE_TOKEN = exports.FILE_ROUTER_TOKEN = exports.WORKSPACE_MANAGER_TOKEN = exports.FILESYSTEM_SERVER_CONFIG_TOKEN = void 0;
9
+ /**
10
+ * Token for FileSystemServerConfig
11
+ */
12
+ exports.FILESYSTEM_SERVER_CONFIG_TOKEN = Symbol('FileSystemServerConfig');
13
+ /**
14
+ * Token for WorkspaceManager service
15
+ */
16
+ exports.WORKSPACE_MANAGER_TOKEN = Symbol('WorkspaceManager');
17
+ /**
18
+ * Token for FileRouter (Express router)
19
+ */
20
+ exports.FILE_ROUTER_TOKEN = Symbol('FileRouter');
21
+ /**
22
+ * Token for main FileSystemService
23
+ */
24
+ exports.FILESYSTEM_SERVICE_TOKEN = Symbol('FileSystemService');
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * @hamak/filesystem-server-api
4
+ *
5
+ * Backend filesystem server API - Public interfaces and types
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ // Export API interfaces
23
+ __exportStar(require("./api/IWorkspaceManager"), exports);
24
+ __exportStar(require("./api/IFileSystemService"), exports);
25
+ __exportStar(require("./api/tokens"), exports);
26
+ // Export types
27
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Types barrel export
4
+ */
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./workspace-config"), exports);
21
+ __exportStar(require("./server-config"), exports);
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * FileSystem Server Configuration Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DEFAULT_FILESYSTEM_SERVER_CONFIG = void 0;
7
+ /**
8
+ * Default configuration values
9
+ */
10
+ exports.DEFAULT_FILESYSTEM_SERVER_CONFIG = {
11
+ enableCors: true,
12
+ enableFileUpload: false,
13
+ maxFileSize: 10 * 1024 * 1024, // 10MB
14
+ mountPath: '/api/workspaces',
15
+ };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Workspace Configuration Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @hamak/filesystem-server-api
3
+ *
4
+ * Backend filesystem server API - Public interfaces and types
5
+ */
6
+ export * from './api/IWorkspaceManager';
7
+ export * from './api/IFileSystemService';
8
+ export * from './api/tokens';
9
+ export * from './types';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @hamak/filesystem-server-api
3
+ *
4
+ * Backend filesystem server API - Public interfaces and types
5
+ */
6
+ // Export API interfaces
7
+ export * from './api/IWorkspaceManager';
8
+ export * from './api/IFileSystemService';
9
+ export * from './api/tokens';
10
+ // Export types
11
+ export * from './types';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Types barrel export
3
+ */
4
+ export * from './workspace-config';
5
+ export * from './server-config';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Types barrel export
3
+ */
4
+ export * from './workspace-config';
5
+ export * from './server-config';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * FileSystem Server Configuration Types
3
+ */
4
+ import { WorkspacesMap } from './workspace-config';
5
+ /**
6
+ * Configuration for the FileSystem Server
7
+ */
8
+ export interface FileSystemServerConfig {
9
+ /**
10
+ * Base directory for all workspaces
11
+ * All workspace paths are resolved relative to this directory
12
+ */
13
+ baseDirectory: string;
14
+ /**
15
+ * Map of workspace IDs to their relative directory paths
16
+ * Example: { "0": "workspace1-directory", "1": "workspace2-directory" }
17
+ */
18
+ workspaces: WorkspacesMap;
19
+ /**
20
+ * Enable CORS for cross-origin requests
21
+ * @default true
22
+ */
23
+ enableCors?: boolean;
24
+ /**
25
+ * Enable file upload functionality
26
+ * @default false
27
+ */
28
+ enableFileUpload?: boolean;
29
+ /**
30
+ * Maximum file size for uploads (in bytes)
31
+ * Only applies if enableFileUpload is true
32
+ * @default 10MB
33
+ */
34
+ maxFileSize?: number;
35
+ /**
36
+ * Mount path for the filesystem API routes
37
+ * @default "/api/workspaces"
38
+ */
39
+ mountPath?: string;
40
+ }
41
+ /**
42
+ * Default configuration values
43
+ */
44
+ export declare const DEFAULT_FILESYSTEM_SERVER_CONFIG: Partial<FileSystemServerConfig>;
45
+ //# sourceMappingURL=server-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/types/server-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,UAAU,EAAE,aAAa,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,gCAAgC,EAAE,OAAO,CAAC,sBAAsB,CAK5E,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * FileSystem Server Configuration Types
3
+ */
4
+ /**
5
+ * Default configuration values
6
+ */
7
+ export const DEFAULT_FILESYSTEM_SERVER_CONFIG = {
8
+ enableCors: true,
9
+ enableFileUpload: false,
10
+ maxFileSize: 10 * 1024 * 1024, // 10MB
11
+ mountPath: '/api/workspaces',
12
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Workspace Configuration Types
3
+ */
4
+ /**
5
+ * Configuration for a single workspace
6
+ */
7
+ export interface WorkspaceConfig {
8
+ /**
9
+ * Unique identifier for the workspace
10
+ */
11
+ id: string;
12
+ /**
13
+ * Relative path from base directory
14
+ */
15
+ relativePath: string;
16
+ /**
17
+ * Display name (optional)
18
+ */
19
+ name?: string;
20
+ /**
21
+ * Description (optional)
22
+ */
23
+ description?: string;
24
+ /**
25
+ * Whether this workspace is read-only
26
+ */
27
+ readOnly?: boolean;
28
+ }
29
+ /**
30
+ * Map of workspace IDs to their relative paths
31
+ * Example: { "0": "workspace1-directory", "1": "workspace2-directory" }
32
+ */
33
+ export type WorkspacesMap = Record<string, string>;
34
+ //# sourceMappingURL=workspace-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-config.d.ts","sourceRoot":"","sources":["../../src/types/workspace-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Workspace Configuration Types
3
+ */
4
+ export {};
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@hamak/filesystem-server-api",
3
+ "version": "0.4.8",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "FileSystem Server API - Backend filesystem server interfaces and contracts",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "sideEffects": false,
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/amah/app-framework.git",
16
+ "directory": "packages/backend/filesystem-server/filesystem-server-api"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "build": "tsc -p tsconfig.json && tsc -p tsconfig.es2015.json",
23
+ "clean": "rm -rf dist",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "require": "./dist/es2015/index.js",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "./es2015": {
35
+ "require": "./dist/es2015/index.js",
36
+ "default": "./dist/es2015/index.js"
37
+ }
38
+ },
39
+ "dependencies": {
40
+ "@hamak/shared-utils": "0.4.7"
41
+ },
42
+ "peerDependencies": {
43
+ "express": "^4.18.0"
44
+ },
45
+ "devDependencies": {
46
+ "@types/express": "^4.17.0",
47
+ "typescript": "~5.4.0",
48
+ "vitest": "^2.0.0"
49
+ }
50
+ }