@veloxts/router 0.4.1 → 0.4.3
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/README.md +21 -674
- package/dist/discovery/errors.d.ts +65 -0
- package/dist/discovery/errors.d.ts.map +1 -0
- package/dist/discovery/errors.js +131 -0
- package/dist/discovery/errors.js.map +1 -0
- package/dist/discovery/index.d.ts +35 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +34 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/loader.d.ts +58 -0
- package/dist/discovery/loader.d.ts.map +1 -0
- package/dist/discovery/loader.js +377 -0
- package/dist/discovery/loader.js.map +1 -0
- package/dist/discovery/types.d.ts +102 -0
- package/dist/discovery/types.d.ts.map +1 -0
- package/dist/discovery/types.js +25 -0
- package/dist/discovery/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure Discovery Errors
|
|
3
|
+
*
|
|
4
|
+
* Error classes and factory functions for the discovery system.
|
|
5
|
+
* Uses E40xx error code range.
|
|
6
|
+
*
|
|
7
|
+
* @module discovery/errors
|
|
8
|
+
*/
|
|
9
|
+
import { DiscoveryErrorCode } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown during procedure discovery operations
|
|
12
|
+
*/
|
|
13
|
+
export declare class DiscoveryError extends Error {
|
|
14
|
+
/** Error code identifier */
|
|
15
|
+
readonly code: DiscoveryErrorCode;
|
|
16
|
+
/** Optional file path where the error occurred */
|
|
17
|
+
readonly filePath?: string;
|
|
18
|
+
/** Suggested fix for the error */
|
|
19
|
+
readonly fix?: string;
|
|
20
|
+
/** Additional error details */
|
|
21
|
+
readonly details?: Record<string, unknown>;
|
|
22
|
+
constructor(code: DiscoveryErrorCode, message: string, options?: {
|
|
23
|
+
readonly filePath?: string;
|
|
24
|
+
readonly fix?: string;
|
|
25
|
+
readonly details?: Record<string, unknown>;
|
|
26
|
+
readonly cause?: Error;
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Format the error for display
|
|
30
|
+
*/
|
|
31
|
+
format(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Convert to JSON for serialization
|
|
34
|
+
*/
|
|
35
|
+
toJSON(): Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Type guard to check if an error is a DiscoveryError
|
|
39
|
+
*/
|
|
40
|
+
export declare function isDiscoveryError(error: unknown): error is DiscoveryError;
|
|
41
|
+
/**
|
|
42
|
+
* Create error for directory not found
|
|
43
|
+
*/
|
|
44
|
+
export declare function directoryNotFound(path: string): DiscoveryError;
|
|
45
|
+
/**
|
|
46
|
+
* Create error for no procedures found
|
|
47
|
+
*/
|
|
48
|
+
export declare function noProceduresFound(path: string, scannedCount: number): DiscoveryError;
|
|
49
|
+
/**
|
|
50
|
+
* Create error for invalid export
|
|
51
|
+
*/
|
|
52
|
+
export declare function invalidExport(filePath: string, exportName: string, reason: string): DiscoveryError;
|
|
53
|
+
/**
|
|
54
|
+
* Create error for file load failure
|
|
55
|
+
*/
|
|
56
|
+
export declare function fileLoadError(filePath: string, cause: Error): DiscoveryError;
|
|
57
|
+
/**
|
|
58
|
+
* Create error for permission denied
|
|
59
|
+
*/
|
|
60
|
+
export declare function permissionDenied(path: string): DiscoveryError;
|
|
61
|
+
/**
|
|
62
|
+
* Create error for invalid file type
|
|
63
|
+
*/
|
|
64
|
+
export declare function invalidFileType(filePath: string, extension: string): DiscoveryError;
|
|
65
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/discovery/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAA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G,cAAc,CAU5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAS7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CAUnF"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure Discovery Errors
|
|
3
|
+
*
|
|
4
|
+
* Error classes and factory functions for the discovery system.
|
|
5
|
+
* Uses E40xx error code range.
|
|
6
|
+
*
|
|
7
|
+
* @module discovery/errors
|
|
8
|
+
*/
|
|
9
|
+
import { DiscoveryErrorCode } from './types.js';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Error Class
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown during procedure discovery operations
|
|
15
|
+
*/
|
|
16
|
+
export class DiscoveryError extends Error {
|
|
17
|
+
/** Error code identifier */
|
|
18
|
+
code;
|
|
19
|
+
/** Optional file path where the error occurred */
|
|
20
|
+
filePath;
|
|
21
|
+
/** Suggested fix for the error */
|
|
22
|
+
fix;
|
|
23
|
+
/** Additional error details */
|
|
24
|
+
details;
|
|
25
|
+
constructor(code, message, options) {
|
|
26
|
+
super(message, { cause: options?.cause });
|
|
27
|
+
this.name = 'DiscoveryError';
|
|
28
|
+
this.code = code;
|
|
29
|
+
this.filePath = options?.filePath;
|
|
30
|
+
this.fix = options?.fix;
|
|
31
|
+
this.details = options?.details;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Format the error for display
|
|
35
|
+
*/
|
|
36
|
+
format() {
|
|
37
|
+
let output = `DiscoveryError[${this.code}]: ${this.message}`;
|
|
38
|
+
if (this.filePath) {
|
|
39
|
+
output += `\n\n File: ${this.filePath}`;
|
|
40
|
+
}
|
|
41
|
+
if (this.fix) {
|
|
42
|
+
output += `\n\n Fix: ${this.fix}`;
|
|
43
|
+
}
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Convert to JSON for serialization
|
|
48
|
+
*/
|
|
49
|
+
toJSON() {
|
|
50
|
+
return {
|
|
51
|
+
code: this.code,
|
|
52
|
+
message: this.message,
|
|
53
|
+
filePath: this.filePath,
|
|
54
|
+
fix: this.fix,
|
|
55
|
+
details: this.details,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// ============================================================================
|
|
60
|
+
// Type Guard
|
|
61
|
+
// ============================================================================
|
|
62
|
+
/**
|
|
63
|
+
* Type guard to check if an error is a DiscoveryError
|
|
64
|
+
*/
|
|
65
|
+
export function isDiscoveryError(error) {
|
|
66
|
+
return error instanceof DiscoveryError;
|
|
67
|
+
}
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// Error Factory Functions
|
|
70
|
+
// ============================================================================
|
|
71
|
+
/**
|
|
72
|
+
* Create error for directory not found
|
|
73
|
+
*/
|
|
74
|
+
export function directoryNotFound(path) {
|
|
75
|
+
return new DiscoveryError(DiscoveryErrorCode.DIRECTORY_NOT_FOUND, `Procedures directory not found: ${path}`, {
|
|
76
|
+
filePath: path,
|
|
77
|
+
fix: 'Create the procedures directory or check the path. Expected structure: src/procedures/*.ts',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create error for no procedures found
|
|
82
|
+
*/
|
|
83
|
+
export function noProceduresFound(path, scannedCount) {
|
|
84
|
+
return new DiscoveryError(DiscoveryErrorCode.NO_PROCEDURES_FOUND, `No procedure collections found in ${path}`, {
|
|
85
|
+
filePath: path,
|
|
86
|
+
details: { scannedFiles: scannedCount },
|
|
87
|
+
fix: scannedCount === 0
|
|
88
|
+
? 'Create procedure files using: velox generate procedure <name>'
|
|
89
|
+
: 'Ensure files export ProcedureCollection objects using defineProcedures()',
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Create error for invalid export
|
|
94
|
+
*/
|
|
95
|
+
export function invalidExport(filePath, exportName, reason) {
|
|
96
|
+
return new DiscoveryError(DiscoveryErrorCode.INVALID_EXPORT, `Invalid export '${exportName}' in ${filePath}: ${reason}`, {
|
|
97
|
+
filePath,
|
|
98
|
+
details: { exportName, reason },
|
|
99
|
+
fix: 'Export must be a ProcedureCollection created with defineProcedures(namespace, procedures)',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create error for file load failure
|
|
104
|
+
*/
|
|
105
|
+
export function fileLoadError(filePath, cause) {
|
|
106
|
+
return new DiscoveryError(DiscoveryErrorCode.FILE_LOAD_ERROR, `Failed to load procedure file: ${filePath} - ${cause.message}`, {
|
|
107
|
+
filePath,
|
|
108
|
+
cause,
|
|
109
|
+
fix: 'Check for syntax errors or missing dependencies in the file',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create error for permission denied
|
|
114
|
+
*/
|
|
115
|
+
export function permissionDenied(path) {
|
|
116
|
+
return new DiscoveryError(DiscoveryErrorCode.PERMISSION_DENIED, `Permission denied accessing: ${path}`, {
|
|
117
|
+
filePath: path,
|
|
118
|
+
fix: 'Check file permissions and ensure the process has read access',
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create error for invalid file type
|
|
123
|
+
*/
|
|
124
|
+
export function invalidFileType(filePath, extension) {
|
|
125
|
+
return new DiscoveryError(DiscoveryErrorCode.INVALID_FILE_TYPE, `Unsupported file type: ${extension}`, {
|
|
126
|
+
filePath,
|
|
127
|
+
details: { extension },
|
|
128
|
+
fix: 'Procedure files must be .ts, .js, .mts, or .mjs',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/discovery/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OA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AAE,EAC/D;QACE,QAAQ;QACR,KAAK;QACL,GAAG,EAAE,6DAA6D;KACnE,CACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,IAAI,cAAc,CACvB,kBAAkB,CAAC,iBAAiB,EACpC,gCAAgC,IAAI,EAAE,EACtC;QACE,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,+DAA+D;KACrE,CACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB,EAAE,SAAiB;IACjE,OAAO,IAAI,cAAc,CACvB,kBAAkB,CAAC,iBAAiB,EACpC,0BAA0B,SAAS,EAAE,EACrC;QACE,QAAQ;QACR,OAAO,EAAE,EAAE,SAAS,EAAE;QACtB,GAAG,EAAE,iDAAiD;KACvD,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure Discovery Module
|
|
3
|
+
*
|
|
4
|
+
* Auto-scan and register procedures from the filesystem.
|
|
5
|
+
*
|
|
6
|
+
* @module discovery
|
|
7
|
+
*
|
|
8
|
+
* @example Basic usage
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { discoverProcedures, rest } from '@veloxts/router';
|
|
11
|
+
*
|
|
12
|
+
* const collections = await discoverProcedures('./src/procedures');
|
|
13
|
+
* await app.register(rest(collections), { prefix: '/api' });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example With options
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const collections = await discoverProcedures('./src/procedures', {
|
|
19
|
+
* recursive: true,
|
|
20
|
+
* onInvalidExport: 'warn',
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Verbose mode for tooling
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const result = await discoverProceduresVerbose('./src/procedures');
|
|
27
|
+
* console.log(`Found ${result.collections.length} collections`);
|
|
28
|
+
* console.log(`Scanned ${result.scannedFiles.length} files`);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export { DiscoveryError, directoryNotFound, fileLoadError, invalidExport, invalidFileType, isDiscoveryError, noProceduresFound, permissionDenied, } from './errors.js';
|
|
32
|
+
export { discoverProcedures, discoverProceduresVerbose } from './loader.js';
|
|
33
|
+
export type { DiscoveryOptions, DiscoveryResult, DiscoveryWarning } from './types.js';
|
|
34
|
+
export { DiscoveryErrorCode } from './types.js';
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure Discovery Module
|
|
3
|
+
*
|
|
4
|
+
* Auto-scan and register procedures from the filesystem.
|
|
5
|
+
*
|
|
6
|
+
* @module discovery
|
|
7
|
+
*
|
|
8
|
+
* @example Basic usage
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { discoverProcedures, rest } from '@veloxts/router';
|
|
11
|
+
*
|
|
12
|
+
* const collections = await discoverProcedures('./src/procedures');
|
|
13
|
+
* await app.register(rest(collections), { prefix: '/api' });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example With options
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const collections = await discoverProcedures('./src/procedures', {
|
|
19
|
+
* recursive: true,
|
|
20
|
+
* onInvalidExport: 'warn',
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example Verbose mode for tooling
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const result = await discoverProceduresVerbose('./src/procedures');
|
|
27
|
+
* console.log(`Found ${result.collections.length} collections`);
|
|
28
|
+
* console.log(`Scanned ${result.scannedFiles.length} files`);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export { DiscoveryError, directoryNotFound, fileLoadError, invalidExport, invalidFileType, isDiscoveryError, noProceduresFound, permissionDenied, } from './errors.js';
|
|
32
|
+
export { discoverProcedures, discoverProceduresVerbose } from './loader.js';
|
|
33
|
+
export { DiscoveryErrorCode } from './types.js';
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/discovery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedure Discovery Loader
|
|
3
|
+
*
|
|
4
|
+
* Core logic for scanning the filesystem and loading procedure collections.
|
|
5
|
+
* Uses dynamic imports with ESM-compatible file URLs.
|
|
6
|
+
*
|
|
7
|
+
* @module discovery/loader
|
|
8
|
+
*/
|
|
9
|
+
import type { ProcedureCollection } from '../types.js';
|
|
10
|
+
import { type DiscoveryOptions, type DiscoveryResult } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Discover procedure collections from the filesystem
|
|
13
|
+
*
|
|
14
|
+
* Scans a directory for files exporting ProcedureCollection objects,
|
|
15
|
+
* validates them at runtime, and returns type-safe results.
|
|
16
|
+
*
|
|
17
|
+
* @param searchPath - Absolute or relative path to procedures directory
|
|
18
|
+
* @param options - Discovery configuration
|
|
19
|
+
* @returns Promise resolving to discovered procedure collections
|
|
20
|
+
*
|
|
21
|
+
* @example Basic usage
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const collections = await discoverProcedures('./src/procedures');
|
|
24
|
+
* await app.register(rest(collections), { prefix: '/api' });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example With options
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const collections = await discoverProcedures('./src/procedures', {
|
|
30
|
+
* recursive: true,
|
|
31
|
+
* cwd: process.cwd(),
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function discoverProcedures(searchPath: string, options?: DiscoveryOptions): Promise<ProcedureCollection[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Discover procedure collections with detailed results
|
|
38
|
+
*
|
|
39
|
+
* Same as discoverProcedures but returns additional metadata about
|
|
40
|
+
* scanned files, loaded files, and any warnings.
|
|
41
|
+
*
|
|
42
|
+
* @param searchPath - Absolute or relative path to procedures directory
|
|
43
|
+
* @param options - Discovery configuration
|
|
44
|
+
* @returns Promise resolving to detailed discovery results
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const result = await discoverProceduresVerbose('./src/procedures', {
|
|
49
|
+
* onInvalidExport: 'warn',
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* console.log(`Found ${result.collections.length} collections`);
|
|
53
|
+
* console.log(`Scanned ${result.scannedFiles.length} files`);
|
|
54
|
+
* result.warnings.forEach(w => console.warn(w.message));
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function discoverProceduresVerbose(searchPath: string, options?: DiscoveryOptions): Promise<DiscoveryResult>;
|
|
58
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/discovery/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AASvD,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAC;AAcpB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAGhC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CAyE1B"}
|