@hamak/filesystem-server-spi 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,27 @@
1
+ "use strict";
2
+ /**
3
+ * @hamak/filesystem-server-spi
4
+ *
5
+ * Backend filesystem server SPI - Extension points
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 SPI interfaces
23
+ __exportStar(require("./spi/IFileSystemMiddleware"), exports);
24
+ __exportStar(require("./spi/IPathResolver"), exports);
25
+ __exportStar(require("./spi/IAccessControl"), exports);
26
+ // Export SPI tokens
27
+ __exportStar(require("./spi/tokens"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Access Control Extension Point
4
+ *
5
+ * Allows custom access control policies for filesystem operations
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * FileSystem Middleware Extension Point
4
+ *
5
+ * Allows plugins to inject custom middleware into the filesystem request pipeline
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Path Resolver Extension Point
4
+ *
5
+ * Allows custom path resolution strategies (e.g., virtual paths, symlinks, etc.)
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * SPI Dependency Injection Tokens
4
+ *
5
+ * Tokens for registering and resolving extension points
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ACCESS_CONTROL_TOKEN = exports.PATH_RESOLVER_TOKEN = exports.FILESYSTEM_MIDDLEWARE_TOKEN = void 0;
9
+ /**
10
+ * Token for custom FileSystem middleware
11
+ * Can be registered multiple times for multiple middleware instances
12
+ */
13
+ exports.FILESYSTEM_MIDDLEWARE_TOKEN = Symbol('FileSystemMiddleware');
14
+ /**
15
+ * Token for custom path resolver
16
+ * Only one resolver should be registered (replaces default)
17
+ */
18
+ exports.PATH_RESOLVER_TOKEN = Symbol('PathResolver');
19
+ /**
20
+ * Token for custom access control
21
+ * Only one access control should be registered (replaces default)
22
+ */
23
+ exports.ACCESS_CONTROL_TOKEN = Symbol('AccessControl');
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @hamak/filesystem-server-spi
3
+ *
4
+ * Backend filesystem server SPI - Extension points
5
+ */
6
+ export * from './spi/IFileSystemMiddleware';
7
+ export * from './spi/IPathResolver';
8
+ export * from './spi/IAccessControl';
9
+ export * from './spi/tokens';
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,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @hamak/filesystem-server-spi
3
+ *
4
+ * Backend filesystem server SPI - Extension points
5
+ */
6
+ // Export SPI interfaces
7
+ export * from './spi/IFileSystemMiddleware';
8
+ export * from './spi/IPathResolver';
9
+ export * from './spi/IAccessControl';
10
+ // Export SPI tokens
11
+ export * from './spi/tokens';
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Access Control Extension Point
3
+ *
4
+ * Allows custom access control policies for filesystem operations
5
+ */
6
+ import { Request } from 'express';
7
+ /**
8
+ * Access control context
9
+ */
10
+ export interface AccessContext {
11
+ /**
12
+ * Express request object
13
+ */
14
+ request: Request;
15
+ /**
16
+ * Workspace ID
17
+ */
18
+ workspace: string;
19
+ /**
20
+ * File path segments
21
+ */
22
+ path: string[];
23
+ /**
24
+ * User information (if available from authentication middleware)
25
+ */
26
+ user?: {
27
+ id: string;
28
+ name?: string;
29
+ roles?: string[];
30
+ [key: string]: any;
31
+ };
32
+ }
33
+ /**
34
+ * Custom access control interface
35
+ */
36
+ export interface IAccessControl {
37
+ /**
38
+ * Check if the current user can read the specified file/directory
39
+ *
40
+ * @param context - Access control context
41
+ * @returns true if read access is allowed
42
+ */
43
+ canRead(context: AccessContext): Promise<boolean>;
44
+ /**
45
+ * Check if the current user can write to the specified file/directory
46
+ *
47
+ * @param context - Access control context
48
+ * @returns true if write access is allowed
49
+ */
50
+ canWrite(context: AccessContext): Promise<boolean>;
51
+ /**
52
+ * Check if the current user can delete the specified file/directory
53
+ *
54
+ * @param context - Access control context
55
+ * @returns true if delete access is allowed
56
+ */
57
+ canDelete(context: AccessContext): Promise<boolean>;
58
+ /**
59
+ * Check if the current user can list the contents of a directory
60
+ *
61
+ * @param context - Access control context
62
+ * @returns true if list access is allowed
63
+ */
64
+ canList(context: AccessContext): Promise<boolean>;
65
+ }
66
+ //# sourceMappingURL=IAccessControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAccessControl.d.ts","sourceRoot":"","sources":["../../src/spi/IAccessControl.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf;;OAEG;IACH,IAAI,CAAC,EAAE;QACL,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAElD;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnD;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Access Control Extension Point
3
+ *
4
+ * Allows custom access control policies for filesystem operations
5
+ */
6
+ export {};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * FileSystem Middleware Extension Point
3
+ *
4
+ * Allows plugins to inject custom middleware into the filesystem request pipeline
5
+ */
6
+ import { Request, Response, NextFunction } from 'express';
7
+ /**
8
+ * Middleware context passed to handlers
9
+ */
10
+ export interface MiddlewareContext {
11
+ /**
12
+ * Workspace ID from the request
13
+ */
14
+ workspace?: string;
15
+ /**
16
+ * File path segments from the request
17
+ */
18
+ path?: string[];
19
+ /**
20
+ * Operation type (list, read, write, delete, mkdir)
21
+ */
22
+ operation?: string;
23
+ }
24
+ /**
25
+ * Custom filesystem middleware interface
26
+ */
27
+ export interface IFileSystemMiddleware {
28
+ /**
29
+ * Priority for middleware execution order
30
+ * Lower numbers execute first
31
+ * @default 100
32
+ */
33
+ priority: number;
34
+ /**
35
+ * Middleware handler function
36
+ * @param req - Express request
37
+ * @param res - Express response
38
+ * @param next - Express next function
39
+ * @param context - Middleware context with workspace and path info
40
+ */
41
+ handle(req: Request, res: Response, next: NextFunction, context?: MiddlewareContext): void | Promise<void>;
42
+ }
43
+ //# sourceMappingURL=IFileSystemMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IFileSystemMiddleware.d.ts","sourceRoot":"","sources":["../../src/spi/IFileSystemMiddleware.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,MAAM,CACJ,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,EAClB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * FileSystem Middleware Extension Point
3
+ *
4
+ * Allows plugins to inject custom middleware into the filesystem request pipeline
5
+ */
6
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Path Resolver Extension Point
3
+ *
4
+ * Allows custom path resolution strategies (e.g., virtual paths, symlinks, etc.)
5
+ */
6
+ /**
7
+ * Custom path resolver interface
8
+ */
9
+ export interface IPathResolver {
10
+ /**
11
+ * Resolve a workspace-relative path to an absolute filesystem path
12
+ *
13
+ * @param workspace - Workspace ID
14
+ * @param filePath - Path segments relative to workspace
15
+ * @returns Absolute filesystem path
16
+ * @throws Error if path is invalid or workspace not found
17
+ */
18
+ resolvePath(workspace: string, filePath: string[]): string;
19
+ /**
20
+ * Validate that a resolved path is safe and within workspace bounds
21
+ *
22
+ * @param resolvedPath - Absolute path to validate
23
+ * @param workspace - Workspace ID for context
24
+ * @returns true if path is valid and safe
25
+ */
26
+ validatePath(resolvedPath: string, workspace: string): boolean;
27
+ /**
28
+ * Normalize path segments (handle '.', '..', etc.)
29
+ *
30
+ * @param pathSegments - Raw path segments
31
+ * @returns Normalized path segments
32
+ */
33
+ normalizePath(pathSegments: string[]): string[];
34
+ }
35
+ //# sourceMappingURL=IPathResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPathResolver.d.ts","sourceRoot":"","sources":["../../src/spi/IPathResolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAE3D;;;;;;OAMG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;IAE/D;;;;;OAKG;IACH,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;CACjD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Path Resolver Extension Point
3
+ *
4
+ * Allows custom path resolution strategies (e.g., virtual paths, symlinks, etc.)
5
+ */
6
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * SPI Dependency Injection Tokens
3
+ *
4
+ * Tokens for registering and resolving extension points
5
+ */
6
+ /**
7
+ * Token for custom FileSystem middleware
8
+ * Can be registered multiple times for multiple middleware instances
9
+ */
10
+ export declare const FILESYSTEM_MIDDLEWARE_TOKEN: unique symbol;
11
+ /**
12
+ * Token for custom path resolver
13
+ * Only one resolver should be registered (replaces default)
14
+ */
15
+ export declare const PATH_RESOLVER_TOKEN: unique symbol;
16
+ /**
17
+ * Token for custom access control
18
+ * Only one access control should be registered (replaces default)
19
+ */
20
+ export declare const ACCESS_CONTROL_TOKEN: unique symbol;
21
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/spi/tokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,eAAO,MAAM,2BAA2B,eAAiC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,mBAAmB,eAAyB,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,eAA0B,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * SPI Dependency Injection Tokens
3
+ *
4
+ * Tokens for registering and resolving extension points
5
+ */
6
+ /**
7
+ * Token for custom FileSystem middleware
8
+ * Can be registered multiple times for multiple middleware instances
9
+ */
10
+ export const FILESYSTEM_MIDDLEWARE_TOKEN = Symbol('FileSystemMiddleware');
11
+ /**
12
+ * Token for custom path resolver
13
+ * Only one resolver should be registered (replaces default)
14
+ */
15
+ export const PATH_RESOLVER_TOKEN = Symbol('PathResolver');
16
+ /**
17
+ * Token for custom access control
18
+ * Only one access control should be registered (replaces default)
19
+ */
20
+ export const ACCESS_CONTROL_TOKEN = Symbol('AccessControl');
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@hamak/filesystem-server-spi",
3
+ "version": "0.4.8",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "FileSystem Server SPI - Backend filesystem server extension points",
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-spi"
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/filesystem-server-api": "0.4.7",
41
+ "@hamak/shared-utils": "0.4.7"
42
+ },
43
+ "peerDependencies": {
44
+ "express": "^4.18.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/express": "^4.17.0",
48
+ "typescript": "~5.4.0",
49
+ "vitest": "^2.0.0"
50
+ }
51
+ }