@weavelogic/knowledge-graph-agent 0.7.4 → 0.8.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.
- package/dist/_virtual/__vite-browser-external.js +2 -2
- package/dist/_virtual/__vite-browser-external.js.map +1 -1
- package/dist/_virtual/browser.js +2 -3
- package/dist/_virtual/browser.js.map +1 -1
- package/dist/_virtual/index10.js +2 -4
- package/dist/_virtual/index10.js.map +1 -1
- package/dist/_virtual/index11.js +2 -2
- package/dist/cli/commands/hive-mind/add-frontmatter.js +2 -2
- package/dist/cli/commands/hive-mind/add-frontmatter.js.map +1 -1
- package/dist/cli/commands/hive-mind/analyze-links.js +2 -2
- package/dist/cli/commands/hive-mind/analyze-links.js.map +1 -1
- package/dist/cli/commands/hive-mind/find-connections.js +2 -2
- package/dist/cli/commands/hive-mind/find-connections.js.map +1 -1
- package/dist/cli/commands/hive-mind/validate-names.js +2 -2
- package/dist/cli/commands/hive-mind/validate-names.js.map +1 -1
- package/dist/graphql/server.js +2 -2
- package/dist/graphql/server.js.map +1 -1
- package/dist/mcp-server/tools/audit/index.d.ts +4 -0
- package/dist/mcp-server/tools/audit/index.d.ts.map +1 -1
- package/dist/node_modules/@typescript-eslint/project-service/dist/index.js +1 -1
- package/dist/node_modules/debug/src/browser.js +1 -1
- package/dist/node_modules/fdir/dist/index.js +14 -14
- package/dist/node_modules/fdir/dist/index.js.map +1 -1
- package/dist/node_modules/tinyglobby/dist/index.js +14 -14
- package/dist/node_modules/tinyglobby/dist/index.js.map +1 -1
- package/dist/node_modules/ts-api-utils/lib/index.js +1 -1
- package/dist/node_modules/typescript/lib/typescript.js +24 -24
- package/dist/node_modules/typescript/lib/typescript.js.map +1 -1
- package/dist/vector/services/embedding-service.js +1 -7
- package/dist/vector/services/embedding-service.js.map +1 -1
- package/package.json +2 -1
- package/dist/_virtual/browser2.js +0 -5
- package/dist/_virtual/browser2.js.map +0 -1
- package/dist/_virtual/index12.js +0 -5
- package/dist/_virtual/index12.js.map +0 -1
- package/dist/_virtual/ort-web.min.js +0 -8
- package/dist/_virtual/ort-web.min.js.map +0 -1
- package/dist/_virtual/ort-web.min2.js +0 -5
- package/dist/_virtual/ort-web.min2.js.map +0 -1
- package/dist/node_modules/@huggingface/jinja/dist/index.js +0 -118
- package/dist/node_modules/@huggingface/jinja/dist/index.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/backends/onnx.js +0 -24
- package/dist/node_modules/@xenova/transformers/src/backends/onnx.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/configs.js +0 -52
- package/dist/node_modules/@xenova/transformers/src/configs.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/env.js +0 -35
- package/dist/node_modules/@xenova/transformers/src/env.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/models.js +0 -3852
- package/dist/node_modules/@xenova/transformers/src/models.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/tokenizers.js +0 -144
- package/dist/node_modules/@xenova/transformers/src/tokenizers.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/utils/core.js +0 -52
- package/dist/node_modules/@xenova/transformers/src/utils/core.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/utils/generation.js +0 -623
- package/dist/node_modules/@xenova/transformers/src/utils/generation.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/utils/hub.js +0 -395
- package/dist/node_modules/@xenova/transformers/src/utils/hub.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/utils/image.js +0 -12
- package/dist/node_modules/@xenova/transformers/src/utils/image.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/utils/maths.js +0 -89
- package/dist/node_modules/@xenova/transformers/src/utils/maths.js.map +0 -1
- package/dist/node_modules/@xenova/transformers/src/utils/tensor.js +0 -750
- package/dist/node_modules/@xenova/transformers/src/utils/tensor.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/backend-impl.js +0 -67
- package/dist/node_modules/onnxruntime-common/dist/lib/backend-impl.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/env-impl.js +0 -24
- package/dist/node_modules/onnxruntime-common/dist/lib/env-impl.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/env.js +0 -6
- package/dist/node_modules/onnxruntime-common/dist/lib/env.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/index.js +0 -11
- package/dist/node_modules/onnxruntime-common/dist/lib/index.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/inference-session-impl.js +0 -162
- package/dist/node_modules/onnxruntime-common/dist/lib/inference-session-impl.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/inference-session.js +0 -6
- package/dist/node_modules/onnxruntime-common/dist/lib/inference-session.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/tensor-impl.js +0 -393
- package/dist/node_modules/onnxruntime-common/dist/lib/tensor-impl.js.map +0 -1
- package/dist/node_modules/onnxruntime-common/dist/lib/tensor.js +0 -6
- package/dist/node_modules/onnxruntime-common/dist/lib/tensor.js.map +0 -1
- package/dist/node_modules/onnxruntime-web/dist/ort-web.min.js +0 -12919
- package/dist/node_modules/onnxruntime-web/dist/ort-web.min.js.map +0 -1
- package/dist/node_modules/ws/browser.js +0 -16
- package/dist/node_modules/ws/browser.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-names.js","sources":["../../../../src/cli/commands/hive-mind/validate-names.ts"],"sourcesContent":["/**\n * Hive Mind - Name Validator\n *\n * Validates file naming schema in a vault to ensure consistent, linkable names.\n * Supports kebab-case, lowercase, and other naming conventions.\n *\n * SPEC-003: Hive Mind Reconnection Tools\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { readdir, rename, access, mkdir, writeFile } from 'fs/promises';\nimport { glob } from 'fast-glob';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ValidateNamesOptions {\n fix?: boolean;\n dryRun?: boolean;\n schema?: string;\n output?: string;\n json?: boolean;\n verbose?: boolean;\n}\n\nexport interface InvalidFile {\n file: string;\n issues: string[];\n suggested: string;\n}\n\nexport interface ValidationResult {\n valid: string[];\n invalid: InvalidFile[];\n statistics: {\n totalFiles: number;\n validCount: number;\n invalidCount: number;\n commonIssues: Map<string, number>;\n };\n}\n\nexport interface NamingSchema {\n name: string;\n patterns: {\n lowercase: boolean;\n separator: '-' | '_' | '.';\n maxLength: number;\n allowedChars: RegExp;\n reservedNames: string[];\n allowMixedSeparators?: boolean;\n };\n}\n\n// ============================================================================\n// Predefined Schemas\n// ============================================================================\n\nconst SCHEMAS: Record<string, NamingSchema> = {\n kebab: {\n name: 'kebab-case',\n patterns: {\n lowercase: true,\n separator: '-',\n maxLength: 100,\n allowedChars: /^[a-z0-9-]+$/,\n reservedNames: ['index', 'readme', 'changelog'],\n },\n },\n snake: {\n name: 'snake_case',\n patterns: {\n lowercase: true,\n separator: '_',\n maxLength: 100,\n allowedChars: /^[a-z0-9_]+$/,\n reservedNames: ['index', 'readme', 'changelog'],\n },\n },\n obsidian: {\n name: 'Obsidian-friendly',\n patterns: {\n lowercase: false,\n separator: '-',\n maxLength: 200,\n allowedChars: /^[a-zA-Z0-9-_ ]+$/,\n reservedNames: [],\n allowMixedSeparators: true,\n },\n },\n};\n\n// ============================================================================\n// Name Validator Class\n// ============================================================================\n\nexport class NameValidator {\n private schema: NamingSchema;\n\n constructor(schemaName = 'kebab') {\n this.schema = SCHEMAS[schemaName] || SCHEMAS.kebab;\n }\n\n /**\n * Validate all files in a vault\n */\n async validateVault(vaultPath: string, options: ValidateNamesOptions = {}): Promise<ValidationResult> {\n const resolvedPath = path.resolve(vaultPath);\n\n // Find all markdown files\n const files = await glob('**/*.md', {\n cwd: resolvedPath,\n ignore: ['node_modules/**', '.git/**', 'dist/**'],\n absolute: false,\n });\n\n if (files.length === 0) {\n throw new Error(`No markdown files found in: ${resolvedPath}`);\n }\n\n const valid: string[] = [];\n const invalid: InvalidFile[] = [];\n const commonIssues = new Map<string, number>();\n\n for (const file of files) {\n const basename = path.basename(file, '.md');\n const issues = this.validateFilename(basename);\n\n if (issues.length === 0) {\n valid.push(file);\n } else {\n const suggested = this.suggestRename(basename);\n\n invalid.push({\n file,\n issues,\n suggested: file.replace(basename + '.md', suggested + '.md'),\n });\n\n // Count issues\n for (const issue of issues) {\n commonIssues.set(issue, (commonIssues.get(issue) || 0) + 1);\n }\n }\n }\n\n return {\n valid,\n invalid,\n statistics: {\n totalFiles: files.length,\n validCount: valid.length,\n invalidCount: invalid.length,\n commonIssues,\n },\n };\n }\n\n /**\n * Validate a single filename\n */\n validateFilename(filename: string): string[] {\n const issues: string[] = [];\n const { patterns } = this.schema;\n\n // Check for uppercase (if lowercase required)\n if (patterns.lowercase && filename !== filename.toLowerCase()) {\n issues.push('Contains uppercase characters');\n }\n\n // Check for spaces (unless pattern allows spaces)\n const allowsSpaces = patterns.allowedChars.test('a b');\n if (!allowsSpaces && filename.includes(' ')) {\n issues.push('Contains spaces');\n }\n\n // Check for special characters\n const testName = patterns.lowercase\n ? filename.toLowerCase()\n : filename;\n if (!patterns.allowedChars.test(testName)) {\n issues.push(`Contains invalid characters (allowed: ${patterns.allowedChars})`);\n }\n\n // Check length\n if (filename.length > patterns.maxLength) {\n issues.push(`Exceeds maximum length (${patterns.maxLength})`);\n }\n\n // Check for consecutive separators\n const doubleSep = patterns.separator + patterns.separator;\n if (filename.includes(doubleSep)) {\n issues.push(`Contains consecutive separators (${doubleSep})`);\n }\n\n // Check for leading/trailing separators\n if (filename.startsWith(patterns.separator) || filename.endsWith(patterns.separator)) {\n issues.push('Starts or ends with separator');\n }\n\n // Check for underscores when using kebab-case (skip if mixed separators allowed)\n if (!patterns.allowMixedSeparators && patterns.separator === '-' && filename.includes('_')) {\n issues.push('Contains underscores (use hyphens)');\n }\n\n // Check for mixed separators (skip if allowed)\n if (!patterns.allowMixedSeparators) {\n if (patterns.separator === '-' && filename.includes('_')) {\n issues.push('Mixed separators (hyphens and underscores)');\n }\n if (patterns.separator === '_' && filename.includes('-')) {\n issues.push('Mixed separators (underscores and hyphens)');\n }\n }\n\n return issues;\n }\n\n /**\n * Suggest a valid filename\n */\n suggestRename(filename: string): string {\n const { patterns } = this.schema;\n\n let suggested = filename;\n\n // Convert to lowercase if required\n if (patterns.lowercase) {\n suggested = suggested.toLowerCase();\n }\n\n // Replace spaces with separator\n suggested = suggested.replace(/\\s+/g, patterns.separator);\n\n // Replace underscores with separator (for kebab-case)\n if (patterns.separator === '-') {\n suggested = suggested.replace(/_+/g, '-');\n }\n\n // Replace hyphens with separator (for snake_case)\n if (patterns.separator === '_') {\n suggested = suggested.replace(/-+/g, '_');\n }\n\n // Remove invalid characters\n suggested = suggested.replace(/[^a-z0-9-_]/g, '');\n\n // Remove consecutive separators\n const sepRegex = new RegExp(`${patterns.separator}+`, 'g');\n suggested = suggested.replace(sepRegex, patterns.separator);\n\n // Remove leading/trailing separators\n suggested = suggested.replace(new RegExp(`^${patterns.separator}+|${patterns.separator}+$`, 'g'), '');\n\n // Truncate if too long\n if (suggested.length > patterns.maxLength) {\n suggested = suggested.substring(0, patterns.maxLength);\n // Clean up any trailing separator after truncation\n suggested = suggested.replace(new RegExp(`${patterns.separator}+$`, 'g'), '');\n }\n\n return suggested || 'untitled';\n }\n\n /**\n * Rename files (with safety checks)\n */\n async renameFiles(\n vaultPath: string,\n invalidFiles: InvalidFile[],\n dryRun = false\n ): Promise<Array<{ from: string; to: string; success: boolean; error?: string }>> {\n const resolvedPath = path.resolve(vaultPath);\n const results: Array<{ from: string; to: string; success: boolean; error?: string }> = [];\n\n for (const { file, suggested } of invalidFiles) {\n const fromPath = path.join(resolvedPath, file);\n const toPath = path.join(resolvedPath, suggested);\n\n // Check if target already exists\n try {\n await access(toPath);\n results.push({\n from: file,\n to: suggested,\n success: false,\n error: 'Target file already exists',\n });\n continue;\n } catch {\n // Target doesn't exist, we can proceed\n }\n\n if (dryRun) {\n results.push({\n from: file,\n to: suggested,\n success: true,\n });\n } else {\n try {\n // Ensure target directory exists\n await mkdir(path.dirname(toPath), { recursive: true });\n await rename(fromPath, toPath);\n results.push({\n from: file,\n to: suggested,\n success: true,\n });\n } catch (error) {\n results.push({\n from: file,\n to: suggested,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n }\n\n return results;\n }\n\n /**\n * Get current schema\n */\n getSchema(): NamingSchema {\n return this.schema;\n }\n\n /**\n * Generate report\n */\n generateReport(result: ValidationResult): string {\n const lines: string[] = [];\n\n lines.push('# File Naming Validation Report\\n');\n lines.push(`Generated: ${new Date().toISOString()}\\n`);\n lines.push(`Schema: ${this.schema.name}\\n`);\n lines.push('');\n\n lines.push('## Summary\\n');\n lines.push(`| Metric | Value |`);\n lines.push(`|--------|-------|`);\n lines.push(`| Total Files | ${result.statistics.totalFiles} |`);\n lines.push(`| Valid | ${result.statistics.validCount} |`);\n lines.push(`| Invalid | ${result.statistics.invalidCount} |`);\n lines.push(`| Compliance | ${((result.statistics.validCount / result.statistics.totalFiles) * 100).toFixed(1)}% |`);\n lines.push('');\n\n if (result.statistics.commonIssues.size > 0) {\n lines.push('## Common Issues\\n');\n const sortedIssues = [...result.statistics.commonIssues.entries()]\n .sort((a, b) => b[1] - a[1]);\n for (const [issue, count] of sortedIssues) {\n lines.push(`- ${issue}: ${count} files`);\n }\n lines.push('');\n }\n\n if (result.invalid.length > 0) {\n lines.push('## Files to Rename\\n');\n lines.push('| Current | Suggested | Issues |');\n lines.push('|---------|-----------|--------|');\n for (const { file, suggested, issues } of result.invalid.slice(0, 50)) {\n lines.push(`| \\`${file}\\` | \\`${suggested}\\` | ${issues.join(', ')} |`);\n }\n if (result.invalid.length > 50) {\n lines.push(`\\n*... and ${result.invalid.length - 50} more*`);\n }\n }\n\n return lines.join('\\n');\n }\n}\n\n// ============================================================================\n// CLI Command\n// ============================================================================\n\nexport function createValidateNamesCommand(): Command {\n const command = new Command('validate-names')\n .description('Validate file naming schema')\n .argument('<vault-path>', 'Path to Obsidian vault or docs directory')\n .option('--schema <name>', 'Naming schema (kebab, snake, obsidian)', 'kebab')\n .option('--fix', 'Auto-rename invalid files')\n .option('--dry-run', 'Show what would be renamed without making changes')\n .option('-o, --output <file>', 'Output file for report')\n .option('--json', 'Output as JSON')\n .option('-v, --verbose', 'Show detailed output')\n .action(async (vaultPath: string, options: ValidateNamesOptions) => {\n const validator = new NameValidator(options.schema || 'kebab');\n\n console.log(chalk.cyan(`\\nValidating file names (${validator.getSchema().name})...\\n`));\n\n try {\n const result = await validator.validateVault(vaultPath, options);\n\n if (options.json) {\n const jsonResult = {\n ...result,\n statistics: {\n ...result.statistics,\n commonIssues: Object.fromEntries(result.statistics.commonIssues),\n },\n };\n\n if (options.output) {\n await writeFile(options.output, JSON.stringify(jsonResult, null, 2));\n console.log(chalk.green(`Results written to: ${options.output}`));\n } else {\n console.log(JSON.stringify(jsonResult, null, 2));\n }\n } else {\n // Display summary\n const compliance = (result.statistics.validCount / result.statistics.totalFiles) * 100;\n const complianceColor = compliance === 100 ? chalk.green : compliance >= 80 ? chalk.yellow : chalk.red;\n\n console.log(chalk.bold('Summary:'));\n console.log(chalk.white(` Total Files: ${result.statistics.totalFiles}`));\n console.log(chalk.green(` Valid: ${result.statistics.validCount}`));\n console.log(chalk.red(` Invalid: ${result.statistics.invalidCount}`));\n console.log(complianceColor(` Compliance: ${compliance.toFixed(1)}%`));\n console.log('');\n\n if (result.statistics.commonIssues.size > 0) {\n console.log(chalk.bold('Common Issues:'));\n const sortedIssues = [...result.statistics.commonIssues.entries()]\n .sort((a, b) => b[1] - a[1]);\n for (const [issue, count] of sortedIssues) {\n console.log(chalk.yellow(` ${count}x ${issue}`));\n }\n console.log('');\n }\n\n if (result.invalid.length > 0 && (options.verbose || options.fix || options.dryRun)) {\n console.log(chalk.bold('Files to Rename:'));\n for (const { file, suggested, issues } of result.invalid.slice(0, options.verbose ? 50 : 10)) {\n console.log(chalk.red(` ${file}`));\n console.log(chalk.green(` -> ${suggested}`));\n if (options.verbose) {\n console.log(chalk.gray(` Issues: ${issues.join(', ')}`));\n }\n }\n if (result.invalid.length > (options.verbose ? 50 : 10)) {\n console.log(chalk.gray(` ... and ${result.invalid.length - (options.verbose ? 50 : 10)} more`));\n }\n console.log('');\n }\n\n // Handle fix/dry-run\n if (options.fix || options.dryRun) {\n const action = options.dryRun ? 'Preview' : 'Rename';\n console.log(chalk.bold(`${action}ing files...`));\n\n const renameResults = await validator.renameFiles(\n vaultPath,\n result.invalid,\n options.dryRun || false\n );\n\n const success = renameResults.filter(r => r.success);\n const failed = renameResults.filter(r => !r.success);\n\n if (options.dryRun) {\n console.log(chalk.cyan(` Would rename ${success.length} files`));\n } else {\n console.log(chalk.green(` Renamed ${success.length} files`));\n }\n\n if (failed.length > 0) {\n console.log(chalk.red(` Failed: ${failed.length} files`));\n if (options.verbose) {\n for (const { from, to, error } of failed) {\n console.log(chalk.red(` ${from} -> ${to}: ${error}`));\n }\n }\n }\n console.log('');\n }\n\n // Write report if output specified\n if (options.output && !options.json) {\n const report = validator.generateReport(result);\n await writeFile(options.output, report);\n console.log(chalk.green(`Report written to: ${options.output}`));\n }\n\n // Show next steps\n if (result.invalid.length > 0 && !options.fix) {\n console.log(chalk.bold('Next Steps:'));\n console.log(chalk.gray(' 1. Review invalid file names'));\n console.log(chalk.gray(' 2. Run with --dry-run to preview changes'));\n console.log(chalk.gray(' 3. Run with --fix to auto-rename files'));\n console.log(chalk.gray(' 4. Update links after renaming with kg analyze-links'));\n console.log('');\n }\n }\n } catch (error) {\n console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');\n process.exit(1);\n }\n });\n\n return command;\n}\n\nexport default createValidateNamesCommand;\n"],"names":[],"mappings":";;;;;AA6DA,MAAM,UAAwC;AAAA,EAC5C,OAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,cAAc;A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AAE;AAAA,QAChB;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,MAAM,IAAI,QAAQ,GAAG,iBAAiB,QAAQ,MAAM,UAAU,eAAe;AAC3F,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;"}
|
|
1
|
+
{"version":3,"file":"validate-names.js","sources":["../../../../src/cli/commands/hive-mind/validate-names.ts"],"sourcesContent":["/**\n * Hive Mind - Name Validator\n *\n * Validates file naming schema in a vault to ensure consistent, linkable names.\n * Supports kebab-case, lowercase, and other naming conventions.\n *\n * SPEC-003: Hive Mind Reconnection Tools\n */\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { readdir, rename, access, mkdir, writeFile } from 'fs/promises';\nimport fg from 'fast-glob';\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ValidateNamesOptions {\n fix?: boolean;\n dryRun?: boolean;\n schema?: string;\n output?: string;\n json?: boolean;\n verbose?: boolean;\n}\n\nexport interface InvalidFile {\n file: string;\n issues: string[];\n suggested: string;\n}\n\nexport interface ValidationResult {\n valid: string[];\n invalid: InvalidFile[];\n statistics: {\n totalFiles: number;\n validCount: number;\n invalidCount: number;\n commonIssues: Map<string, number>;\n };\n}\n\nexport interface NamingSchema {\n name: string;\n patterns: {\n lowercase: boolean;\n separator: '-' | '_' | '.';\n maxLength: number;\n allowedChars: RegExp;\n reservedNames: string[];\n allowMixedSeparators?: boolean;\n };\n}\n\n// ============================================================================\n// Predefined Schemas\n// ============================================================================\n\nconst SCHEMAS: Record<string, NamingSchema> = {\n kebab: {\n name: 'kebab-case',\n patterns: {\n lowercase: true,\n separator: '-',\n maxLength: 100,\n allowedChars: /^[a-z0-9-]+$/,\n reservedNames: ['index', 'readme', 'changelog'],\n },\n },\n snake: {\n name: 'snake_case',\n patterns: {\n lowercase: true,\n separator: '_',\n maxLength: 100,\n allowedChars: /^[a-z0-9_]+$/,\n reservedNames: ['index', 'readme', 'changelog'],\n },\n },\n obsidian: {\n name: 'Obsidian-friendly',\n patterns: {\n lowercase: false,\n separator: '-',\n maxLength: 200,\n allowedChars: /^[a-zA-Z0-9-_ ]+$/,\n reservedNames: [],\n allowMixedSeparators: true,\n },\n },\n};\n\n// ============================================================================\n// Name Validator Class\n// ============================================================================\n\nexport class NameValidator {\n private schema: NamingSchema;\n\n constructor(schemaName = 'kebab') {\n this.schema = SCHEMAS[schemaName] || SCHEMAS.kebab;\n }\n\n /**\n * Validate all files in a vault\n */\n async validateVault(vaultPath: string, options: ValidateNamesOptions = {}): Promise<ValidationResult> {\n const resolvedPath = path.resolve(vaultPath);\n\n // Find all markdown files\n const files = await fg('**/*.md', {\n cwd: resolvedPath,\n ignore: ['node_modules/**', '.git/**', 'dist/**'],\n absolute: false,\n });\n\n if (files.length === 0) {\n throw new Error(`No markdown files found in: ${resolvedPath}`);\n }\n\n const valid: string[] = [];\n const invalid: InvalidFile[] = [];\n const commonIssues = new Map<string, number>();\n\n for (const file of files) {\n const basename = path.basename(file, '.md');\n const issues = this.validateFilename(basename);\n\n if (issues.length === 0) {\n valid.push(file);\n } else {\n const suggested = this.suggestRename(basename);\n\n invalid.push({\n file,\n issues,\n suggested: file.replace(basename + '.md', suggested + '.md'),\n });\n\n // Count issues\n for (const issue of issues) {\n commonIssues.set(issue, (commonIssues.get(issue) || 0) + 1);\n }\n }\n }\n\n return {\n valid,\n invalid,\n statistics: {\n totalFiles: files.length,\n validCount: valid.length,\n invalidCount: invalid.length,\n commonIssues,\n },\n };\n }\n\n /**\n * Validate a single filename\n */\n validateFilename(filename: string): string[] {\n const issues: string[] = [];\n const { patterns } = this.schema;\n\n // Check for uppercase (if lowercase required)\n if (patterns.lowercase && filename !== filename.toLowerCase()) {\n issues.push('Contains uppercase characters');\n }\n\n // Check for spaces (unless pattern allows spaces)\n const allowsSpaces = patterns.allowedChars.test('a b');\n if (!allowsSpaces && filename.includes(' ')) {\n issues.push('Contains spaces');\n }\n\n // Check for special characters\n const testName = patterns.lowercase\n ? filename.toLowerCase()\n : filename;\n if (!patterns.allowedChars.test(testName)) {\n issues.push(`Contains invalid characters (allowed: ${patterns.allowedChars})`);\n }\n\n // Check length\n if (filename.length > patterns.maxLength) {\n issues.push(`Exceeds maximum length (${patterns.maxLength})`);\n }\n\n // Check for consecutive separators\n const doubleSep = patterns.separator + patterns.separator;\n if (filename.includes(doubleSep)) {\n issues.push(`Contains consecutive separators (${doubleSep})`);\n }\n\n // Check for leading/trailing separators\n if (filename.startsWith(patterns.separator) || filename.endsWith(patterns.separator)) {\n issues.push('Starts or ends with separator');\n }\n\n // Check for underscores when using kebab-case (skip if mixed separators allowed)\n if (!patterns.allowMixedSeparators && patterns.separator === '-' && filename.includes('_')) {\n issues.push('Contains underscores (use hyphens)');\n }\n\n // Check for mixed separators (skip if allowed)\n if (!patterns.allowMixedSeparators) {\n if (patterns.separator === '-' && filename.includes('_')) {\n issues.push('Mixed separators (hyphens and underscores)');\n }\n if (patterns.separator === '_' && filename.includes('-')) {\n issues.push('Mixed separators (underscores and hyphens)');\n }\n }\n\n return issues;\n }\n\n /**\n * Suggest a valid filename\n */\n suggestRename(filename: string): string {\n const { patterns } = this.schema;\n\n let suggested = filename;\n\n // Convert to lowercase if required\n if (patterns.lowercase) {\n suggested = suggested.toLowerCase();\n }\n\n // Replace spaces with separator\n suggested = suggested.replace(/\\s+/g, patterns.separator);\n\n // Replace underscores with separator (for kebab-case)\n if (patterns.separator === '-') {\n suggested = suggested.replace(/_+/g, '-');\n }\n\n // Replace hyphens with separator (for snake_case)\n if (patterns.separator === '_') {\n suggested = suggested.replace(/-+/g, '_');\n }\n\n // Remove invalid characters\n suggested = suggested.replace(/[^a-z0-9-_]/g, '');\n\n // Remove consecutive separators\n const sepRegex = new RegExp(`${patterns.separator}+`, 'g');\n suggested = suggested.replace(sepRegex, patterns.separator);\n\n // Remove leading/trailing separators\n suggested = suggested.replace(new RegExp(`^${patterns.separator}+|${patterns.separator}+$`, 'g'), '');\n\n // Truncate if too long\n if (suggested.length > patterns.maxLength) {\n suggested = suggested.substring(0, patterns.maxLength);\n // Clean up any trailing separator after truncation\n suggested = suggested.replace(new RegExp(`${patterns.separator}+$`, 'g'), '');\n }\n\n return suggested || 'untitled';\n }\n\n /**\n * Rename files (with safety checks)\n */\n async renameFiles(\n vaultPath: string,\n invalidFiles: InvalidFile[],\n dryRun = false\n ): Promise<Array<{ from: string; to: string; success: boolean; error?: string }>> {\n const resolvedPath = path.resolve(vaultPath);\n const results: Array<{ from: string; to: string; success: boolean; error?: string }> = [];\n\n for (const { file, suggested } of invalidFiles) {\n const fromPath = path.join(resolvedPath, file);\n const toPath = path.join(resolvedPath, suggested);\n\n // Check if target already exists\n try {\n await access(toPath);\n results.push({\n from: file,\n to: suggested,\n success: false,\n error: 'Target file already exists',\n });\n continue;\n } catch {\n // Target doesn't exist, we can proceed\n }\n\n if (dryRun) {\n results.push({\n from: file,\n to: suggested,\n success: true,\n });\n } else {\n try {\n // Ensure target directory exists\n await mkdir(path.dirname(toPath), { recursive: true });\n await rename(fromPath, toPath);\n results.push({\n from: file,\n to: suggested,\n success: true,\n });\n } catch (error) {\n results.push({\n from: file,\n to: suggested,\n success: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n });\n }\n }\n }\n\n return results;\n }\n\n /**\n * Get current schema\n */\n getSchema(): NamingSchema {\n return this.schema;\n }\n\n /**\n * Generate report\n */\n generateReport(result: ValidationResult): string {\n const lines: string[] = [];\n\n lines.push('# File Naming Validation Report\\n');\n lines.push(`Generated: ${new Date().toISOString()}\\n`);\n lines.push(`Schema: ${this.schema.name}\\n`);\n lines.push('');\n\n lines.push('## Summary\\n');\n lines.push(`| Metric | Value |`);\n lines.push(`|--------|-------|`);\n lines.push(`| Total Files | ${result.statistics.totalFiles} |`);\n lines.push(`| Valid | ${result.statistics.validCount} |`);\n lines.push(`| Invalid | ${result.statistics.invalidCount} |`);\n lines.push(`| Compliance | ${((result.statistics.validCount / result.statistics.totalFiles) * 100).toFixed(1)}% |`);\n lines.push('');\n\n if (result.statistics.commonIssues.size > 0) {\n lines.push('## Common Issues\\n');\n const sortedIssues = [...result.statistics.commonIssues.entries()]\n .sort((a, b) => b[1] - a[1]);\n for (const [issue, count] of sortedIssues) {\n lines.push(`- ${issue}: ${count} files`);\n }\n lines.push('');\n }\n\n if (result.invalid.length > 0) {\n lines.push('## Files to Rename\\n');\n lines.push('| Current | Suggested | Issues |');\n lines.push('|---------|-----------|--------|');\n for (const { file, suggested, issues } of result.invalid.slice(0, 50)) {\n lines.push(`| \\`${file}\\` | \\`${suggested}\\` | ${issues.join(', ')} |`);\n }\n if (result.invalid.length > 50) {\n lines.push(`\\n*... and ${result.invalid.length - 50} more*`);\n }\n }\n\n return lines.join('\\n');\n }\n}\n\n// ============================================================================\n// CLI Command\n// ============================================================================\n\nexport function createValidateNamesCommand(): Command {\n const command = new Command('validate-names')\n .description('Validate file naming schema')\n .argument('<vault-path>', 'Path to Obsidian vault or docs directory')\n .option('--schema <name>', 'Naming schema (kebab, snake, obsidian)', 'kebab')\n .option('--fix', 'Auto-rename invalid files')\n .option('--dry-run', 'Show what would be renamed without making changes')\n .option('-o, --output <file>', 'Output file for report')\n .option('--json', 'Output as JSON')\n .option('-v, --verbose', 'Show detailed output')\n .action(async (vaultPath: string, options: ValidateNamesOptions) => {\n const validator = new NameValidator(options.schema || 'kebab');\n\n console.log(chalk.cyan(`\\nValidating file names (${validator.getSchema().name})...\\n`));\n\n try {\n const result = await validator.validateVault(vaultPath, options);\n\n if (options.json) {\n const jsonResult = {\n ...result,\n statistics: {\n ...result.statistics,\n commonIssues: Object.fromEntries(result.statistics.commonIssues),\n },\n };\n\n if (options.output) {\n await writeFile(options.output, JSON.stringify(jsonResult, null, 2));\n console.log(chalk.green(`Results written to: ${options.output}`));\n } else {\n console.log(JSON.stringify(jsonResult, null, 2));\n }\n } else {\n // Display summary\n const compliance = (result.statistics.validCount / result.statistics.totalFiles) * 100;\n const complianceColor = compliance === 100 ? chalk.green : compliance >= 80 ? chalk.yellow : chalk.red;\n\n console.log(chalk.bold('Summary:'));\n console.log(chalk.white(` Total Files: ${result.statistics.totalFiles}`));\n console.log(chalk.green(` Valid: ${result.statistics.validCount}`));\n console.log(chalk.red(` Invalid: ${result.statistics.invalidCount}`));\n console.log(complianceColor(` Compliance: ${compliance.toFixed(1)}%`));\n console.log('');\n\n if (result.statistics.commonIssues.size > 0) {\n console.log(chalk.bold('Common Issues:'));\n const sortedIssues = [...result.statistics.commonIssues.entries()]\n .sort((a, b) => b[1] - a[1]);\n for (const [issue, count] of sortedIssues) {\n console.log(chalk.yellow(` ${count}x ${issue}`));\n }\n console.log('');\n }\n\n if (result.invalid.length > 0 && (options.verbose || options.fix || options.dryRun)) {\n console.log(chalk.bold('Files to Rename:'));\n for (const { file, suggested, issues } of result.invalid.slice(0, options.verbose ? 50 : 10)) {\n console.log(chalk.red(` ${file}`));\n console.log(chalk.green(` -> ${suggested}`));\n if (options.verbose) {\n console.log(chalk.gray(` Issues: ${issues.join(', ')}`));\n }\n }\n if (result.invalid.length > (options.verbose ? 50 : 10)) {\n console.log(chalk.gray(` ... and ${result.invalid.length - (options.verbose ? 50 : 10)} more`));\n }\n console.log('');\n }\n\n // Handle fix/dry-run\n if (options.fix || options.dryRun) {\n const action = options.dryRun ? 'Preview' : 'Rename';\n console.log(chalk.bold(`${action}ing files...`));\n\n const renameResults = await validator.renameFiles(\n vaultPath,\n result.invalid,\n options.dryRun || false\n );\n\n const success = renameResults.filter(r => r.success);\n const failed = renameResults.filter(r => !r.success);\n\n if (options.dryRun) {\n console.log(chalk.cyan(` Would rename ${success.length} files`));\n } else {\n console.log(chalk.green(` Renamed ${success.length} files`));\n }\n\n if (failed.length > 0) {\n console.log(chalk.red(` Failed: ${failed.length} files`));\n if (options.verbose) {\n for (const { from, to, error } of failed) {\n console.log(chalk.red(` ${from} -> ${to}: ${error}`));\n }\n }\n }\n console.log('');\n }\n\n // Write report if output specified\n if (options.output && !options.json) {\n const report = validator.generateReport(result);\n await writeFile(options.output, report);\n console.log(chalk.green(`Report written to: ${options.output}`));\n }\n\n // Show next steps\n if (result.invalid.length > 0 && !options.fix) {\n console.log(chalk.bold('Next Steps:'));\n console.log(chalk.gray(' 1. Review invalid file names'));\n console.log(chalk.gray(' 2. Run with --dry-run to preview changes'));\n console.log(chalk.gray(' 3. Run with --fix to auto-rename files'));\n console.log(chalk.gray(' 4. Update links after renaming with kg analyze-links'));\n console.log('');\n }\n }\n } catch (error) {\n console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');\n process.exit(1);\n }\n });\n\n return command;\n}\n\nexport default createValidateNamesCommand;\n"],"names":[],"mappings":";;;;;AA6DA,MAAM,UAAwC;AAAA,EAC5C,OAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,MACd,eAAe,CAAC,SAAS,UAAU,WAAW;AAAA,IAAA;AAAA,EAChD;AAAA,EAEF,OAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,MACd,eAAe,CAAC,SAAS,UAAU,WAAW;AAAA,IAAA;AAAA,EAChD;AAAA,EAEF,UAAU;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,MACR,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,cAAc;AAAA,MACd,eAAe,CAAA;AAAA,MACf,sBAAsB;AAAA,IAAA;AAAA,EACxB;AAEJ;AAMO,MAAM,cAAc;AAAA,EACjB;AAAA,EAER,YAAY,aAAa,SAAS;AAChC,SAAK,SAAS,QAAQ,UAAU,KAAK,QAAQ;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAAc,WAAmB,UAAgC,IAA+B;AACpG,UAAM,eAAe,KAAK,QAAQ,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A,cACzD;AAAA,YACF;AAAA,UACF;AACA,kBAAQ,IAAI,EAAE;AAAA,QAChB;AAGA,YAAI,QAAQ,UAAU,CAAC,QAAQ,MAAM;AACnC,gBAAM,SAAS,UAAU,eAAe,MAAM;AAC9C,gBAAM,UAAU,QAAQ,QAAQ,MAAM;AACtC,kBAAQ,IAAI,MAAM,MAAM,sBAAsB,QAAQ,MAAM,EAAE,CAAC;AAAA,QACjE;AAGA,YAAI,OAAO,QAAQ,SAAS,KAAK,CAAC,QAAQ,KAAK;AAC7C,kBAAQ,IAAI,MAAM,KAAK,aAAa,CAAC;AACrC,kBAAQ,IAAI,MAAM,KAAK,gCAAgC,CAAC;AACxD,kBAAQ,IAAI,MAAM,KAAK,4CAA4C,CAAC;AACpE,kBAAQ,IAAI,MAAM,KAAK,0CAA0C,CAAC;AAClE,kBAAQ,IAAI,MAAM,KAAK,wDAAwD,CAAC;AAChF,kBAAQ,IAAI,EAAE;AAAA,QAChB;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,MAAM,IAAI,QAAQ,GAAG,iBAAiB,QAAQ,MAAM,UAAU,eAAe;AAC3F,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;"}
|
package/dist/graphql/server.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createServer } from "http";
|
|
|
2
2
|
import { existsSync, readFileSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { useServer } from "../node_modules/graphql-ws/lib/use/ws.js";
|
|
5
|
-
import {
|
|
5
|
+
import { WebSocketServer } from "ws";
|
|
6
6
|
import { createLogger } from "../utils/logger.js";
|
|
7
7
|
import { createContextFactory } from "./context.js";
|
|
8
8
|
import { customScalars } from "./scalars.js";
|
|
@@ -92,7 +92,7 @@ function createGraphQLServer(config) {
|
|
|
92
92
|
yoga.handle(req, res);
|
|
93
93
|
});
|
|
94
94
|
if (enableSubscriptions) {
|
|
95
|
-
wsServer = new
|
|
95
|
+
wsServer = new WebSocketServer({
|
|
96
96
|
server: httpServer,
|
|
97
97
|
path: graphqlPath
|
|
98
98
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sources":["../../src/graphql/server.ts"],"sourcesContent":["/**\n * GraphQL Server Setup\n *\n * Provides GraphQL server configuration using graphql-yoga with WebSocket\n * subscriptions, CORS configuration, health checks, and GraphiQL playground.\n *\n * @module graphql/server\n */\n\nimport { createServer, type IncomingMessage, type ServerResponse, type Server } from 'http';\nimport { readFileSync, existsSync } from 'fs';\nimport { join } from 'path';\nimport { createYoga, type YogaServerInstance } from 'graphql-yoga';\nimport { useServer } from 'graphql-ws/lib/use/ws';\nimport { WebSocketServer } from 'ws';\nimport { makeExecutableSchema } from '@graphql-tools/schema';\n\nimport { createLogger } from '../utils/index.js';\nimport { createContextFactory, type GraphQLContext, type ContextFactoryConfig } from './context.js';\nimport { customScalars } from './scalars.js';\nimport type { KnowledgeGraphDatabase } from '../core/database.js';\nimport type { AdvancedCache } from '../caching/lru-cache.js';\nimport type { ServiceManager } from '../services/index.js';\n\nconst logger = createLogger('graphql-server');\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * GraphQL server configuration options\n */\nexport interface GraphQLServerConfig {\n /** Port to listen on */\n port: number;\n /** Host to bind to */\n host?: string;\n /** Path for GraphQL endpoint */\n graphqlPath?: string;\n /** Path for health check endpoint */\n healthPath?: string;\n /** Enable GraphiQL playground */\n enableGraphiQL?: boolean;\n /** Enable WebSocket subscriptions */\n enableSubscriptions?: boolean;\n /** CORS configuration */\n cors?: CorsConfig;\n /** Database instance */\n database: KnowledgeGraphDatabase;\n /** Cache instance */\n cache: AdvancedCache<unknown>;\n /** Service manager instance */\n serviceManager: ServiceManager;\n /** API key for authentication (optional) */\n apiKey?: string;\n /** Whether to require authentication */\n requireAuth?: boolean;\n /** Custom resolvers (merged with defaults) */\n resolvers?: Record<string, unknown>;\n /** Custom schema path (default: src/graphql/schema.graphql) */\n schemaPath?: string;\n}\n\n/**\n * CORS configuration options\n */\nexport interface CorsConfig {\n /** Allowed origins (string or array) */\n origin?: string | string[] | boolean;\n /** Allowed methods */\n methods?: string[];\n /** Allowed headers */\n allowedHeaders?: string[];\n /** Exposed headers */\n exposedHeaders?: string[];\n /** Allow credentials */\n credentials?: boolean;\n /** Max age for preflight cache (seconds) */\n maxAge?: number;\n}\n\n/**\n * Health check response\n */\nexport interface HealthCheckResponse {\n status: 'healthy' | 'degraded' | 'unhealthy';\n timestamp: string;\n uptime: number;\n version: string;\n components: {\n database: boolean;\n cache: boolean;\n services: boolean;\n };\n}\n\n/**\n * GraphQL server instance with lifecycle methods\n */\nexport interface GraphQLServerInstance {\n /** Start the server */\n start(): Promise<void>;\n /** Stop the server gracefully */\n stop(): Promise<void>;\n /** Get the HTTP server instance */\n getHttpServer(): Server;\n /** Get the Yoga instance */\n getYoga(): YogaServerInstance<Record<string, unknown>, GraphQLContext>;\n /** Check if server is running */\n isRunning(): boolean;\n /** Get server URL */\n getUrl(): string;\n}\n\n// ============================================================================\n// Server Factory\n// ============================================================================\n\n/**\n * Create a GraphQL server with all configured features\n *\n * @param config - Server configuration\n * @returns GraphQL server instance\n *\n * @example\n * ```typescript\n * const server = createGraphQLServer({\n * port: 4000,\n * database,\n * cache,\n * serviceManager,\n * enableGraphiQL: true,\n * enableSubscriptions: true,\n * cors: {\n * origin: ['http://localhost:3000'],\n * credentials: true,\n * },\n * });\n *\n * await server.start();\n * console.log(`GraphQL server running at ${server.getUrl()}`);\n * ```\n */\nexport function createGraphQLServer(config: GraphQLServerConfig): GraphQLServerInstance {\n const {\n port,\n host = '0.0.0.0',\n graphqlPath = '/graphql',\n healthPath = '/health',\n enableGraphiQL = true,\n enableSubscriptions = true,\n cors = {},\n database,\n cache,\n serviceManager,\n apiKey,\n requireAuth = false,\n resolvers: customResolvers = {},\n schemaPath,\n } = config;\n\n let httpServer: Server | null = null;\n let wsServer: WebSocketServer | null = null;\n let isServerRunning = false;\n const startTime = Date.now();\n\n // Load schema\n const typeDefs = loadSchema(schemaPath);\n\n // Create resolvers with custom scalars\n const resolvers = {\n ...customScalars,\n ...createDefaultResolvers(),\n ...customResolvers,\n };\n\n // Create executable schema\n const schema = makeExecutableSchema({\n typeDefs,\n resolvers,\n });\n\n // Create context factory\n const contextFactory = createContextFactory({\n database,\n cache,\n serviceManager,\n apiKey,\n requireAuth,\n });\n\n // Create CORS configuration\n const corsConfig = buildCorsConfig(cors);\n\n // Create Yoga instance\n const yoga = createYoga<Record<string, unknown>, GraphQLContext>({\n schema,\n context: contextFactory,\n graphqlEndpoint: graphqlPath,\n graphiql: enableGraphiQL\n ? {\n title: 'Knowledge Graph API',\n defaultQuery: DEFAULT_QUERY,\n subscriptionsProtocol: 'WS',\n }\n : false,\n cors: {\n origin: Array.isArray(corsConfig.origin) ? corsConfig.origin : corsConfig.origin === true ? '*' : [],\n methods: corsConfig.methods,\n allowedHeaders: corsConfig.allowedHeaders,\n exposedHeaders: corsConfig.exposedHeaders,\n credentials: corsConfig.credentials,\n maxAge: corsConfig.maxAge,\n },\n logging: {\n debug: (...args) => logger.debug('GraphQL', { args }),\n info: (...args) => logger.info(args.join(' ')),\n warn: (...args) => logger.warn(args.join(' ')),\n error: (...args) => logger.error(args.join(' ')),\n },\n maskedErrors: process.env.NODE_ENV === 'production',\n landingPage: false,\n });\n\n // Create HTTP server with health check\n httpServer = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n // Handle health check\n if (req.url === healthPath && req.method === 'GET') {\n const health = await getHealthCheck(database, cache, serviceManager, startTime);\n const statusCode = health.status === 'healthy' ? 200 : health.status === 'degraded' ? 200 : 503;\n\n res.writeHead(statusCode, {\n 'Content-Type': 'application/json',\n 'Cache-Control': 'no-cache, no-store, must-revalidate',\n });\n res.end(JSON.stringify(health));\n return;\n }\n\n // Handle CORS preflight\n if (req.method === 'OPTIONS') {\n handleCorsPreFlight(req, res, corsConfig);\n return;\n }\n\n // Delegate to Yoga - yoga.handle returns void and writes directly to response\n yoga.handle(req, res);\n });\n\n // Setup WebSocket server for subscriptions\n if (enableSubscriptions) {\n wsServer = new WebSocketServer({\n server: httpServer,\n path: graphqlPath,\n });\n\n useServer(\n {\n schema,\n context: async (ctx) => {\n // Create context from WebSocket connection\n const request = new Request(`ws://${host}:${port}${graphqlPath}`, {\n headers: ctx.connectionParams as Record<string, string> | undefined,\n });\n return contextFactory({ request });\n },\n onConnect: () => {\n logger.info('WebSocket client connected');\n return true;\n },\n onDisconnect: (ctx, code, reason) => {\n logger.info('WebSocket client disconnected', { code, reason: reason?.toString() });\n },\n onError: (ctx, message, errors) => {\n logger.error('WebSocket error', undefined, { message, errors });\n },\n },\n wsServer\n );\n\n logger.info('WebSocket subscriptions enabled', { path: graphqlPath });\n }\n\n // Return server instance\n return {\n async start(): Promise<void> {\n if (isServerRunning) {\n logger.warn('Server already running');\n return;\n }\n\n return new Promise((resolve, reject) => {\n httpServer!.listen(port, host, () => {\n isServerRunning = true;\n logger.info('GraphQL server started', {\n url: `http://${host}:${port}${graphqlPath}`,\n graphiql: enableGraphiQL ? `http://${host}:${port}${graphqlPath}` : 'disabled',\n health: `http://${host}:${port}${healthPath}`,\n subscriptions: enableSubscriptions ? `ws://${host}:${port}${graphqlPath}` : 'disabled',\n });\n resolve();\n });\n\n httpServer!.on('error', (error) => {\n logger.error('Server error', error);\n reject(error);\n });\n });\n },\n\n async stop(): Promise<void> {\n if (!isServerRunning) {\n return;\n }\n\n logger.info('Stopping GraphQL server...');\n\n // Close WebSocket server\n if (wsServer) {\n await new Promise<void>((resolve) => {\n wsServer!.close(() => {\n logger.debug('WebSocket server closed');\n resolve();\n });\n });\n }\n\n // Close HTTP server\n await new Promise<void>((resolve, reject) => {\n httpServer!.close((error) => {\n if (error) {\n reject(error);\n } else {\n isServerRunning = false;\n logger.info('GraphQL server stopped');\n resolve();\n }\n });\n });\n },\n\n getHttpServer(): Server {\n return httpServer!;\n },\n\n getYoga() {\n return yoga;\n },\n\n isRunning(): boolean {\n return isServerRunning;\n },\n\n getUrl(): string {\n return `http://${host}:${port}${graphqlPath}`;\n },\n };\n}\n\n// ============================================================================\n// Schema Loading\n// ============================================================================\n\n/**\n * Load GraphQL schema from file\n */\nfunction loadSchema(customPath?: string): string {\n // Try custom path first\n if (customPath && existsSync(customPath)) {\n logger.debug('Loading schema from custom path', { path: customPath });\n return readFileSync(customPath, 'utf-8');\n }\n\n // Schema search paths (relative to cwd)\n const searchPaths = [\n join(process.cwd(), 'src/graphql/schema.graphql'),\n join(process.cwd(), 'graphql/schema.graphql'),\n join(process.cwd(), 'schema.graphql'),\n // For dist builds\n join(process.cwd(), 'dist/graphql/schema.graphql'),\n ];\n\n for (const schemaPath of searchPaths) {\n if (existsSync(schemaPath)) {\n logger.debug('Loading schema from path', { path: schemaPath });\n return readFileSync(schemaPath, 'utf-8');\n }\n }\n\n throw new Error(\n `GraphQL schema not found. Tried: ${[customPath, ...searchPaths].filter(Boolean).join(', ')}`\n );\n}\n\n// ============================================================================\n// Default Resolvers\n// ============================================================================\n\n/**\n * Create default resolvers for system queries\n */\nfunction createDefaultResolvers(): Record<string, unknown> {\n return {\n Query: {\n // System health query\n health: async (\n _parent: unknown,\n _args: unknown,\n context: GraphQLContext\n ): Promise<{\n status: string;\n components: { database: boolean; cache: boolean; agents: boolean; vectorStore: boolean };\n uptime: number;\n requestCount: number;\n toolCount: number;\n }> => {\n const { services } = context;\n const dbHealthy = !!services.database;\n const cacheHealthy = !!services.cache;\n\n return {\n status: dbHealthy && cacheHealthy ? 'HEALTHY' : 'DEGRADED',\n components: {\n database: dbHealthy,\n cache: cacheHealthy,\n agents: true, // Would check agent registry\n vectorStore: false, // Not implemented yet\n },\n uptime: process.uptime() * 1000,\n requestCount: 0, // Would track in context\n toolCount: 0, // Would count MCP tools\n };\n },\n\n // Version info query\n version: (): {\n version: string;\n buildTime: Date | null;\n gitCommit: string | null;\n nodeVersion: string;\n schemaVersion: string;\n } => ({\n version: process.env.npm_package_version ?? '0.0.0',\n buildTime: null,\n gitCommit: process.env.GIT_COMMIT ?? null,\n nodeVersion: process.version,\n schemaVersion: '1.0.0',\n }),\n },\n\n // Subscription resolvers would be added here\n Subscription: {},\n };\n}\n\n// ============================================================================\n// CORS Helpers\n// ============================================================================\n\n/**\n * Build CORS configuration for Yoga\n */\nfunction buildCorsConfig(cors: CorsConfig): {\n origin: string[] | boolean;\n methods: string[];\n allowedHeaders: string[];\n exposedHeaders: string[];\n credentials: boolean;\n maxAge: number;\n} {\n const origin = cors.origin === true\n ? true\n : cors.origin === false\n ? false\n : Array.isArray(cors.origin)\n ? cors.origin\n : cors.origin\n ? [cors.origin]\n : ['http://localhost:3000', 'http://localhost:5173']; // Default dashboard origins\n\n return {\n origin: origin === false ? [] : origin,\n methods: cors.methods ?? ['GET', 'POST', 'OPTIONS'],\n allowedHeaders: cors.allowedHeaders ?? ['Content-Type', 'Authorization', 'X-Request-ID'],\n exposedHeaders: cors.exposedHeaders ?? ['X-Request-ID'],\n credentials: cors.credentials ?? true,\n maxAge: cors.maxAge ?? 86400, // 24 hours\n };\n}\n\n/**\n * Handle CORS preflight request\n */\nfunction handleCorsPreFlight(\n req: import('http').IncomingMessage,\n res: import('http').ServerResponse,\n corsConfig: ReturnType<typeof buildCorsConfig>\n): void {\n const origin = req.headers.origin;\n\n if (origin && (corsConfig.origin === true || (Array.isArray(corsConfig.origin) && corsConfig.origin.includes(origin)))) {\n res.setHeader('Access-Control-Allow-Origin', origin);\n }\n\n res.setHeader('Access-Control-Allow-Methods', corsConfig.methods.join(', '));\n res.setHeader('Access-Control-Allow-Headers', corsConfig.allowedHeaders.join(', '));\n res.setHeader('Access-Control-Max-Age', corsConfig.maxAge.toString());\n\n if (corsConfig.credentials) {\n res.setHeader('Access-Control-Allow-Credentials', 'true');\n }\n\n res.writeHead(204);\n res.end();\n}\n\n// ============================================================================\n// Health Check\n// ============================================================================\n\n/**\n * Get health check response\n */\nasync function getHealthCheck(\n database: KnowledgeGraphDatabase,\n cache: AdvancedCache<unknown>,\n serviceManager: ServiceManager,\n startTime: number\n): Promise<HealthCheckResponse> {\n let dbHealthy = false;\n let cacheHealthy = false;\n let servicesHealthy = false;\n\n try {\n // Check database\n const db = database.getDatabase();\n db.prepare('SELECT 1').get();\n dbHealthy = true;\n } catch (error) {\n logger.error('Database health check failed', error instanceof Error ? error : undefined);\n }\n\n try {\n // Check cache\n cache.set('_health_check', Date.now(), { ttl: 1000 });\n const value = cache.get('_health_check');\n cacheHealthy = value !== undefined;\n cache.delete('_health_check');\n } catch (error) {\n logger.error('Cache health check failed', error instanceof Error ? error : undefined);\n }\n\n try {\n // Check services\n const states = serviceManager.getAllStates();\n const runningCount = Array.from(states.values()).filter((s) => s.status === 'running').length;\n servicesHealthy = runningCount >= 0; // At least no errors\n } catch (error) {\n logger.error('Services health check failed', error instanceof Error ? error : undefined);\n }\n\n const allHealthy = dbHealthy && cacheHealthy && servicesHealthy;\n const anyHealthy = dbHealthy || cacheHealthy || servicesHealthy;\n\n return {\n status: allHealthy ? 'healthy' : anyHealthy ? 'degraded' : 'unhealthy',\n timestamp: new Date().toISOString(),\n uptime: Date.now() - startTime,\n version: process.env.npm_package_version ?? '0.0.0',\n components: {\n database: dbHealthy,\n cache: cacheHealthy,\n services: servicesHealthy,\n },\n };\n}\n\n// ============================================================================\n// Default Query for GraphiQL\n// ============================================================================\n\nconst DEFAULT_QUERY = `# Welcome to the Knowledge Graph API\n#\n# Try these example queries:\n\nquery SystemHealth {\n health {\n status\n components {\n database\n cache\n agents\n vectorStore\n }\n uptime\n requestCount\n toolCount\n }\n}\n\nquery SystemVersion {\n version {\n version\n nodeVersion\n schemaVersion\n }\n}\n\n# Uncomment to query graph stats:\n# query GraphStats {\n# graphStats {\n# totalNodes\n# totalEdges\n# nodesByType {\n# type\n# count\n# }\n# orphanNodes\n# avgLinksPerNode\n# }\n# }\n\n# Uncomment to search nodes:\n# query SearchNodes($query: String!) {\n# search(query: $query) {\n# totalMatches\n# nodes {\n# id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,YAAY,aAAa,aAAa;AAAA,IAC3D,YAAW,oBAAI,KAAA,GAAO,YAAA;AAAA,IACtB,QAAQ,KAAK,IAAA,IAAQ;AAAA,IACrB,SAAS,QAAQ,IAAI,uBAAuB;AAAA,IAC5C,YAAY;AAAA,MACV,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAAA,EACZ;AAEJ;AAMA,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
1
|
+
{"version":3,"file":"server.js","sources":["../../src/graphql/server.ts"],"sourcesContent":["/**\n * GraphQL Server Setup\n *\n * Provides GraphQL server configuration using graphql-yoga with WebSocket\n * subscriptions, CORS configuration, health checks, and GraphiQL playground.\n *\n * @module graphql/server\n */\n\nimport { createServer, type IncomingMessage, type ServerResponse, type Server } from 'http';\nimport { readFileSync, existsSync } from 'fs';\nimport { join } from 'path';\nimport { createYoga, type YogaServerInstance } from 'graphql-yoga';\nimport { useServer } from 'graphql-ws/lib/use/ws';\nimport { WebSocketServer } from 'ws';\nimport { makeExecutableSchema } from '@graphql-tools/schema';\n\nimport { createLogger } from '../utils/index.js';\nimport { createContextFactory, type GraphQLContext, type ContextFactoryConfig } from './context.js';\nimport { customScalars } from './scalars.js';\nimport type { KnowledgeGraphDatabase } from '../core/database.js';\nimport type { AdvancedCache } from '../caching/lru-cache.js';\nimport type { ServiceManager } from '../services/index.js';\n\nconst logger = createLogger('graphql-server');\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * GraphQL server configuration options\n */\nexport interface GraphQLServerConfig {\n /** Port to listen on */\n port: number;\n /** Host to bind to */\n host?: string;\n /** Path for GraphQL endpoint */\n graphqlPath?: string;\n /** Path for health check endpoint */\n healthPath?: string;\n /** Enable GraphiQL playground */\n enableGraphiQL?: boolean;\n /** Enable WebSocket subscriptions */\n enableSubscriptions?: boolean;\n /** CORS configuration */\n cors?: CorsConfig;\n /** Database instance */\n database: KnowledgeGraphDatabase;\n /** Cache instance */\n cache: AdvancedCache<unknown>;\n /** Service manager instance */\n serviceManager: ServiceManager;\n /** API key for authentication (optional) */\n apiKey?: string;\n /** Whether to require authentication */\n requireAuth?: boolean;\n /** Custom resolvers (merged with defaults) */\n resolvers?: Record<string, unknown>;\n /** Custom schema path (default: src/graphql/schema.graphql) */\n schemaPath?: string;\n}\n\n/**\n * CORS configuration options\n */\nexport interface CorsConfig {\n /** Allowed origins (string or array) */\n origin?: string | string[] | boolean;\n /** Allowed methods */\n methods?: string[];\n /** Allowed headers */\n allowedHeaders?: string[];\n /** Exposed headers */\n exposedHeaders?: string[];\n /** Allow credentials */\n credentials?: boolean;\n /** Max age for preflight cache (seconds) */\n maxAge?: number;\n}\n\n/**\n * Health check response\n */\nexport interface HealthCheckResponse {\n status: 'healthy' | 'degraded' | 'unhealthy';\n timestamp: string;\n uptime: number;\n version: string;\n components: {\n database: boolean;\n cache: boolean;\n services: boolean;\n };\n}\n\n/**\n * GraphQL server instance with lifecycle methods\n */\nexport interface GraphQLServerInstance {\n /** Start the server */\n start(): Promise<void>;\n /** Stop the server gracefully */\n stop(): Promise<void>;\n /** Get the HTTP server instance */\n getHttpServer(): Server;\n /** Get the Yoga instance */\n getYoga(): YogaServerInstance<Record<string, unknown>, GraphQLContext>;\n /** Check if server is running */\n isRunning(): boolean;\n /** Get server URL */\n getUrl(): string;\n}\n\n// ============================================================================\n// Server Factory\n// ============================================================================\n\n/**\n * Create a GraphQL server with all configured features\n *\n * @param config - Server configuration\n * @returns GraphQL server instance\n *\n * @example\n * ```typescript\n * const server = createGraphQLServer({\n * port: 4000,\n * database,\n * cache,\n * serviceManager,\n * enableGraphiQL: true,\n * enableSubscriptions: true,\n * cors: {\n * origin: ['http://localhost:3000'],\n * credentials: true,\n * },\n * });\n *\n * await server.start();\n * console.log(`GraphQL server running at ${server.getUrl()}`);\n * ```\n */\nexport function createGraphQLServer(config: GraphQLServerConfig): GraphQLServerInstance {\n const {\n port,\n host = '0.0.0.0',\n graphqlPath = '/graphql',\n healthPath = '/health',\n enableGraphiQL = true,\n enableSubscriptions = true,\n cors = {},\n database,\n cache,\n serviceManager,\n apiKey,\n requireAuth = false,\n resolvers: customResolvers = {},\n schemaPath,\n } = config;\n\n let httpServer: Server | null = null;\n let wsServer: WebSocketServer | null = null;\n let isServerRunning = false;\n const startTime = Date.now();\n\n // Load schema\n const typeDefs = loadSchema(schemaPath);\n\n // Create resolvers with custom scalars\n const resolvers = {\n ...customScalars,\n ...createDefaultResolvers(),\n ...customResolvers,\n };\n\n // Create executable schema\n const schema = makeExecutableSchema({\n typeDefs,\n resolvers,\n });\n\n // Create context factory\n const contextFactory = createContextFactory({\n database,\n cache,\n serviceManager,\n apiKey,\n requireAuth,\n });\n\n // Create CORS configuration\n const corsConfig = buildCorsConfig(cors);\n\n // Create Yoga instance\n const yoga = createYoga<Record<string, unknown>, GraphQLContext>({\n schema,\n context: contextFactory,\n graphqlEndpoint: graphqlPath,\n graphiql: enableGraphiQL\n ? {\n title: 'Knowledge Graph API',\n defaultQuery: DEFAULT_QUERY,\n subscriptionsProtocol: 'WS',\n }\n : false,\n cors: {\n origin: Array.isArray(corsConfig.origin) ? corsConfig.origin : corsConfig.origin === true ? '*' : [],\n methods: corsConfig.methods,\n allowedHeaders: corsConfig.allowedHeaders,\n exposedHeaders: corsConfig.exposedHeaders,\n credentials: corsConfig.credentials,\n maxAge: corsConfig.maxAge,\n },\n logging: {\n debug: (...args) => logger.debug('GraphQL', { args }),\n info: (...args) => logger.info(args.join(' ')),\n warn: (...args) => logger.warn(args.join(' ')),\n error: (...args) => logger.error(args.join(' ')),\n },\n maskedErrors: process.env.NODE_ENV === 'production',\n landingPage: false,\n });\n\n // Create HTTP server with health check\n httpServer = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n // Handle health check\n if (req.url === healthPath && req.method === 'GET') {\n const health = await getHealthCheck(database, cache, serviceManager, startTime);\n const statusCode = health.status === 'healthy' ? 200 : health.status === 'degraded' ? 200 : 503;\n\n res.writeHead(statusCode, {\n 'Content-Type': 'application/json',\n 'Cache-Control': 'no-cache, no-store, must-revalidate',\n });\n res.end(JSON.stringify(health));\n return;\n }\n\n // Handle CORS preflight\n if (req.method === 'OPTIONS') {\n handleCorsPreFlight(req, res, corsConfig);\n return;\n }\n\n // Delegate to Yoga - yoga.handle returns void and writes directly to response\n yoga.handle(req, res);\n });\n\n // Setup WebSocket server for subscriptions\n if (enableSubscriptions) {\n wsServer = new WebSocketServer({\n server: httpServer,\n path: graphqlPath,\n });\n\n useServer(\n {\n schema,\n context: async (ctx) => {\n // Create context from WebSocket connection\n const request = new Request(`ws://${host}:${port}${graphqlPath}`, {\n headers: ctx.connectionParams as Record<string, string> | undefined,\n });\n return contextFactory({ request });\n },\n onConnect: () => {\n logger.info('WebSocket client connected');\n return true;\n },\n onDisconnect: (ctx, code, reason) => {\n logger.info('WebSocket client disconnected', { code, reason: reason?.toString() });\n },\n onError: (ctx, message, errors) => {\n logger.error('WebSocket error', undefined, { message, errors });\n },\n },\n wsServer\n );\n\n logger.info('WebSocket subscriptions enabled', { path: graphqlPath });\n }\n\n // Return server instance\n return {\n async start(): Promise<void> {\n if (isServerRunning) {\n logger.warn('Server already running');\n return;\n }\n\n return new Promise((resolve, reject) => {\n httpServer!.listen(port, host, () => {\n isServerRunning = true;\n logger.info('GraphQL server started', {\n url: `http://${host}:${port}${graphqlPath}`,\n graphiql: enableGraphiQL ? `http://${host}:${port}${graphqlPath}` : 'disabled',\n health: `http://${host}:${port}${healthPath}`,\n subscriptions: enableSubscriptions ? `ws://${host}:${port}${graphqlPath}` : 'disabled',\n });\n resolve();\n });\n\n httpServer!.on('error', (error) => {\n logger.error('Server error', error);\n reject(error);\n });\n });\n },\n\n async stop(): Promise<void> {\n if (!isServerRunning) {\n return;\n }\n\n logger.info('Stopping GraphQL server...');\n\n // Close WebSocket server\n if (wsServer) {\n await new Promise<void>((resolve) => {\n wsServer!.close(() => {\n logger.debug('WebSocket server closed');\n resolve();\n });\n });\n }\n\n // Close HTTP server\n await new Promise<void>((resolve, reject) => {\n httpServer!.close((error) => {\n if (error) {\n reject(error);\n } else {\n isServerRunning = false;\n logger.info('GraphQL server stopped');\n resolve();\n }\n });\n });\n },\n\n getHttpServer(): Server {\n return httpServer!;\n },\n\n getYoga() {\n return yoga;\n },\n\n isRunning(): boolean {\n return isServerRunning;\n },\n\n getUrl(): string {\n return `http://${host}:${port}${graphqlPath}`;\n },\n };\n}\n\n// ============================================================================\n// Schema Loading\n// ============================================================================\n\n/**\n * Load GraphQL schema from file\n */\nfunction loadSchema(customPath?: string): string {\n // Try custom path first\n if (customPath && existsSync(customPath)) {\n logger.debug('Loading schema from custom path', { path: customPath });\n return readFileSync(customPath, 'utf-8');\n }\n\n // Schema search paths (relative to cwd)\n const searchPaths = [\n join(process.cwd(), 'src/graphql/schema.graphql'),\n join(process.cwd(), 'graphql/schema.graphql'),\n join(process.cwd(), 'schema.graphql'),\n // For dist builds\n join(process.cwd(), 'dist/graphql/schema.graphql'),\n ];\n\n for (const schemaPath of searchPaths) {\n if (existsSync(schemaPath)) {\n logger.debug('Loading schema from path', { path: schemaPath });\n return readFileSync(schemaPath, 'utf-8');\n }\n }\n\n throw new Error(\n `GraphQL schema not found. Tried: ${[customPath, ...searchPaths].filter(Boolean).join(', ')}`\n );\n}\n\n// ============================================================================\n// Default Resolvers\n// ============================================================================\n\n/**\n * Create default resolvers for system queries\n */\nfunction createDefaultResolvers(): Record<string, unknown> {\n return {\n Query: {\n // System health query\n health: async (\n _parent: unknown,\n _args: unknown,\n context: GraphQLContext\n ): Promise<{\n status: string;\n components: { database: boolean; cache: boolean; agents: boolean; vectorStore: boolean };\n uptime: number;\n requestCount: number;\n toolCount: number;\n }> => {\n const { services } = context;\n const dbHealthy = !!services.database;\n const cacheHealthy = !!services.cache;\n\n return {\n status: dbHealthy && cacheHealthy ? 'HEALTHY' : 'DEGRADED',\n components: {\n database: dbHealthy,\n cache: cacheHealthy,\n agents: true, // Would check agent registry\n vectorStore: false, // Not implemented yet\n },\n uptime: process.uptime() * 1000,\n requestCount: 0, // Would track in context\n toolCount: 0, // Would count MCP tools\n };\n },\n\n // Version info query\n version: (): {\n version: string;\n buildTime: Date | null;\n gitCommit: string | null;\n nodeVersion: string;\n schemaVersion: string;\n } => ({\n version: process.env.npm_package_version ?? '0.0.0',\n buildTime: null,\n gitCommit: process.env.GIT_COMMIT ?? null,\n nodeVersion: process.version,\n schemaVersion: '1.0.0',\n }),\n },\n\n // Subscription resolvers would be added here\n Subscription: {},\n };\n}\n\n// ============================================================================\n// CORS Helpers\n// ============================================================================\n\n/**\n * Build CORS configuration for Yoga\n */\nfunction buildCorsConfig(cors: CorsConfig): {\n origin: string[] | boolean;\n methods: string[];\n allowedHeaders: string[];\n exposedHeaders: string[];\n credentials: boolean;\n maxAge: number;\n} {\n const origin = cors.origin === true\n ? true\n : cors.origin === false\n ? false\n : Array.isArray(cors.origin)\n ? cors.origin\n : cors.origin\n ? [cors.origin]\n : ['http://localhost:3000', 'http://localhost:5173']; // Default dashboard origins\n\n return {\n origin: origin === false ? [] : origin,\n methods: cors.methods ?? ['GET', 'POST', 'OPTIONS'],\n allowedHeaders: cors.allowedHeaders ?? ['Content-Type', 'Authorization', 'X-Request-ID'],\n exposedHeaders: cors.exposedHeaders ?? ['X-Request-ID'],\n credentials: cors.credentials ?? true,\n maxAge: cors.maxAge ?? 86400, // 24 hours\n };\n}\n\n/**\n * Handle CORS preflight request\n */\nfunction handleCorsPreFlight(\n req: import('http').IncomingMessage,\n res: import('http').ServerResponse,\n corsConfig: ReturnType<typeof buildCorsConfig>\n): void {\n const origin = req.headers.origin;\n\n if (origin && (corsConfig.origin === true || (Array.isArray(corsConfig.origin) && corsConfig.origin.includes(origin)))) {\n res.setHeader('Access-Control-Allow-Origin', origin);\n }\n\n res.setHeader('Access-Control-Allow-Methods', corsConfig.methods.join(', '));\n res.setHeader('Access-Control-Allow-Headers', corsConfig.allowedHeaders.join(', '));\n res.setHeader('Access-Control-Max-Age', corsConfig.maxAge.toString());\n\n if (corsConfig.credentials) {\n res.setHeader('Access-Control-Allow-Credentials', 'true');\n }\n\n res.writeHead(204);\n res.end();\n}\n\n// ============================================================================\n// Health Check\n// ============================================================================\n\n/**\n * Get health check response\n */\nasync function getHealthCheck(\n database: KnowledgeGraphDatabase,\n cache: AdvancedCache<unknown>,\n serviceManager: ServiceManager,\n startTime: number\n): Promise<HealthCheckResponse> {\n let dbHealthy = false;\n let cacheHealthy = false;\n let servicesHealthy = false;\n\n try {\n // Check database\n const db = database.getDatabase();\n db.prepare('SELECT 1').get();\n dbHealthy = true;\n } catch (error) {\n logger.error('Database health check failed', error instanceof Error ? error : undefined);\n }\n\n try {\n // Check cache\n cache.set('_health_check', Date.now(), { ttl: 1000 });\n const value = cache.get('_health_check');\n cacheHealthy = value !== undefined;\n cache.delete('_health_check');\n } catch (error) {\n logger.error('Cache health check failed', error instanceof Error ? error : undefined);\n }\n\n try {\n // Check services\n const states = serviceManager.getAllStates();\n const runningCount = Array.from(states.values()).filter((s) => s.status === 'running').length;\n servicesHealthy = runningCount >= 0; // At least no errors\n } catch (error) {\n logger.error('Services health check failed', error instanceof Error ? error : undefined);\n }\n\n const allHealthy = dbHealthy && cacheHealthy && servicesHealthy;\n const anyHealthy = dbHealthy || cacheHealthy || servicesHealthy;\n\n return {\n status: allHealthy ? 'healthy' : anyHealthy ? 'degraded' : 'unhealthy',\n timestamp: new Date().toISOString(),\n uptime: Date.now() - startTime,\n version: process.env.npm_package_version ?? '0.0.0',\n components: {\n database: dbHealthy,\n cache: cacheHealthy,\n services: servicesHealthy,\n },\n };\n}\n\n// ============================================================================\n// Default Query for GraphiQL\n// ============================================================================\n\nconst DEFAULT_QUERY = `# Welcome to the Knowledge Graph API\n#\n# Try these example queries:\n\nquery SystemHealth {\n health {\n status\n components {\n database\n cache\n agents\n vectorStore\n }\n uptime\n requestCount\n toolCount\n }\n}\n\nquery SystemVersion {\n version {\n version\n nodeVersion\n schemaVersion\n }\n}\n\n# Uncomment to query graph stats:\n# query GraphStats {\n# graphStats {\n# totalNodes\n# totalEdges\n# nodesByType {\n# type\n# count\n# }\n# orphanNodes\n# avgLinksPerNode\n# }\n# }\n\n# Uncomment to search nodes:\n# query SearchNodes($query: String!) {\n# search(query: $query) {\n# totalMatches\n# nodes {\n# id\n# title\n# type\n# tags\n# }\n# }\n# }\n`;\n"],"names":[],"mappings":";;;;;;;;;;AAwBA,MAAM,SAAS,aAAa,gBAAgB;AAwHrC,SAAS,oBAAoB,QAAoD;AACtF,QAAM;AAAA,IACJ;AAAA,IACA,OAAO;AAAA,IACP,cAAc;AAAA,IACd,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,sBAAsB;AAAA,IACtB,OAAO,CAAA;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,WAAW,kBAAkB,CAAA;AAAA,IAC7B;AAAA,EAAA,IACE;AAEJ,MAAI,aAA4B;AAChC,MAAI,WAAmC;AACvC,MAAI,kBAAkB;AACtB,QAAM,YAAY,KAAK,IAAA;AAGvB,QAAM,WAAW,WAAW,UAAU;AAGtC,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG,uBAAA;AAAA,IACH,GAAG;AAAA,EAAA;AAIL,QAAM,SAAS,qBAAqB;AAAA,IAClC;AAAA,IACA;AAAA,EAAA,CACD;AAGD,QAAM,iBAAiB,qBAAqB;AAAA,IAC1C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,E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AO,eAAe;AAAA,EAC9B,SAAS,OAAO;AACd,WAAO,MAAM,6BAA6B,iBAAiB,QAAQ,QAAQ,MAAS;AAAA,EACtF;AAEA,MAAI;AAEF,UAAM,SAAS,eAAe,aAAA;AAC9B,UAAM,eAAe,MAAM,KAAK,OAAO,OAAA,CAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,SAAS,EAAE;AACvF,sBAAkB,gBAAgB;AAAA,EACpC,SAAS,OAAO;AACd,WAAO,MAAM,gCAAgC,iBAAiB,QAAQ,QAAQ,MAAS;AAAA,EACzF;AAEA,QAAM,aAAa,aAAa,gBAAgB;AAChD,QAAM,aAAa,aAAa,gBAAgB;AAEhD,SAAO;AAAA,IACL,QAAQ,aAAa,YAAY,aAAa,aAAa;AAAA,IAC3D,YAAW,oBAAI,KAAA,GAAO,YAAA;AAAA,IACtB,QAAQ,KAAK,IAAA,IAAQ;AAAA,IACrB,SAAS,QAAQ,IAAI,uBAAuB;AAAA,IAC5C,YAAY;AAAA,MACV,UAAU;AAAA,MACV,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAAA,EACZ;AAEJ;AAMA,MAAM,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;"}
|
|
@@ -40,6 +40,9 @@ export declare const auditToolDefinitions: {
|
|
|
40
40
|
idempotentHint?: boolean | undefined;
|
|
41
41
|
openWorldHint?: boolean | undefined;
|
|
42
42
|
} | undefined;
|
|
43
|
+
execution?: {
|
|
44
|
+
taskSupport?: "required" | "optional" | "forbidden" | undefined;
|
|
45
|
+
} | undefined;
|
|
43
46
|
_meta?: {
|
|
44
47
|
[x: string]: unknown;
|
|
45
48
|
} | undefined;
|
|
@@ -47,6 +50,7 @@ export declare const auditToolDefinitions: {
|
|
|
47
50
|
src: string;
|
|
48
51
|
mimeType?: string | undefined;
|
|
49
52
|
sizes?: string[] | undefined;
|
|
53
|
+
theme?: "light" | "dark" | undefined;
|
|
50
54
|
}[] | undefined;
|
|
51
55
|
title?: string | undefined;
|
|
52
56
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/audit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AAMnB;;GAEG;AACH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/audit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,qBAAqB,GAC3B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AAMnB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIhC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as dist } from "../../../../_virtual/
|
|
1
|
+
import { __exports as dist } from "../../../../_virtual/index7.js";
|
|
2
2
|
import { __require as requireCreateProjectService } from "./createProjectService.js";
|
|
3
3
|
var hasRequiredDist;
|
|
4
4
|
function requireDist() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { __exports as dist } from "../../../_virtual/
|
|
1
|
+
import { __exports as dist } from "../../../_virtual/index10.js";
|
|
2
2
|
import path__default from "path";
|
|
3
|
-
import
|
|
3
|
+
import require$$1 from "fs";
|
|
4
4
|
import { __require as requirePicomatch } from "../../picomatch/index.js";
|
|
5
5
|
var hasRequiredDist;
|
|
6
6
|
function requireDist() {
|
|
@@ -27,7 +27,7 @@ function requireDist() {
|
|
|
27
27
|
enumerable: true
|
|
28
28
|
}) : target, mod));
|
|
29
29
|
const path = __toESM(path__default);
|
|
30
|
-
const fs
|
|
30
|
+
const fs = __toESM(require$$1);
|
|
31
31
|
function cleanPath(path$1) {
|
|
32
32
|
let normalized = (0, path.normalize)(path$1);
|
|
33
33
|
if (normalized.length > 1 && normalized[normalized.length - 1] === path.sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
@@ -139,11 +139,11 @@ function requireDist() {
|
|
|
139
139
|
return options.group ? groupFiles : empty;
|
|
140
140
|
}
|
|
141
141
|
const resolveSymlinksAsync = function(path$1, state, callback$1) {
|
|
142
|
-
const { queue, fs: fs$
|
|
142
|
+
const { queue, fs: fs$1, options: { suppressErrors } } = state;
|
|
143
143
|
queue.enqueue();
|
|
144
|
-
fs$
|
|
144
|
+
fs$1.realpath(path$1, (error, resolvedPath) => {
|
|
145
145
|
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
146
|
-
fs$
|
|
146
|
+
fs$1.stat(resolvedPath, (error$1, stat) => {
|
|
147
147
|
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
148
148
|
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
149
149
|
callback$1(stat, resolvedPath);
|
|
@@ -152,11 +152,11 @@ function requireDist() {
|
|
|
152
152
|
});
|
|
153
153
|
};
|
|
154
154
|
const resolveSymlinks = function(path$1, state, callback$1) {
|
|
155
|
-
const { queue, fs: fs$
|
|
155
|
+
const { queue, fs: fs$1, options: { suppressErrors } } = state;
|
|
156
156
|
queue.enqueue();
|
|
157
157
|
try {
|
|
158
|
-
const resolvedPath = fs$
|
|
159
|
-
const stat = fs$
|
|
158
|
+
const resolvedPath = fs$1.realpathSync(path$1);
|
|
159
|
+
const stat = fs$1.statSync(resolvedPath);
|
|
160
160
|
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
161
161
|
callback$1(stat, resolvedPath);
|
|
162
162
|
} catch (e) {
|
|
@@ -226,22 +226,22 @@ function requireDist() {
|
|
|
226
226
|
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
227
227
|
state.queue.enqueue();
|
|
228
228
|
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
229
|
-
const { fs: fs$
|
|
229
|
+
const { fs: fs$1 } = state;
|
|
230
230
|
state.visited.push(crawlPath);
|
|
231
231
|
state.counts.directories++;
|
|
232
|
-
fs$
|
|
232
|
+
fs$1.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
233
233
|
callback$1(entries, directoryPath, currentDepth);
|
|
234
234
|
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
235
235
|
});
|
|
236
236
|
};
|
|
237
237
|
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
238
|
-
const { fs: fs$
|
|
238
|
+
const { fs: fs$1 } = state;
|
|
239
239
|
if (currentDepth < 0) return;
|
|
240
240
|
state.visited.push(crawlPath);
|
|
241
241
|
state.counts.directories++;
|
|
242
242
|
let entries = [];
|
|
243
243
|
try {
|
|
244
|
-
entries = fs$
|
|
244
|
+
entries = fs$1.readdirSync(crawlPath || ".", readdirOpts);
|
|
245
245
|
} catch (e) {
|
|
246
246
|
if (!state.options.suppressErrors) throw e;
|
|
247
247
|
}
|
|
@@ -324,7 +324,7 @@ function requireDist() {
|
|
|
324
324
|
symlinks: /* @__PURE__ */ new Map(),
|
|
325
325
|
visited: [""].slice(0, 0),
|
|
326
326
|
controller: new Aborter(),
|
|
327
|
-
fs: options.fs || fs
|
|
327
|
+
fs: options.fs || fs
|
|
328
328
|
};
|
|
329
329
|
this.joinPath = build$7(this.root, options);
|
|
330
330
|
this.pushDirectory = build$6(this.root, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../node_modules/fdir/dist/index.cjs"],"sourcesContent":["//#region rolldown:runtime\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {\n\t\tkey = keys[i];\n\t\tif (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: ((k) => from[k]).bind(null, key),\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n\tvalue: mod,\n\tenumerable: true\n}) : target, mod));\n\n//#endregion\nconst path = __toESM(require(\"path\"));\nconst fs = __toESM(require(\"fs\"));\n\n//#region src/utils.ts\nfunction cleanPath(path$1) {\n\tlet normalized = (0, path.normalize)(path$1);\n\tif (normalized.length > 1 && normalized[normalized.length - 1] === path.sep) normalized = normalized.substring(0, normalized.length - 1);\n\treturn normalized;\n}\nconst SLASHES_REGEX = /[\\\\/]/g;\nfunction convertSlashes(path$1, separator) {\n\treturn path$1.replace(SLASHES_REGEX, separator);\n}\nconst WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\\\/]$/i;\nfunction isRootDirectory(path$1) {\n\treturn path$1 === \"/\" || WINDOWS_ROOT_DIR_REGEX.test(path$1);\n}\nfunction normalizePath(path$1, options) {\n\tconst { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;\n\tconst pathNeedsCleaning = process.platform === \"win32\" && path$1.includes(\"/\") || path$1.startsWith(\".\");\n\tif (resolvePaths) path$1 = (0, path.resolve)(path$1);\n\tif (normalizePath$1 || pathNeedsCleaning) path$1 = cleanPath(path$1);\n\tif (path$1 === \".\") return \"\";\n\tconst needsSeperator = path$1[path$1.length - 1] !== pathSeparator;\n\treturn convertSlashes(needsSeperator ? path$1 + pathSeparator : path$1, pathSeparator);\n}\n\n//#endregion\n//#region src/api/functions/join-path.ts\nfunction joinPathWithBasePath(filename, directoryPath) {\n\treturn directoryPath + filename;\n}\nfunction joinPathWithRelativePath(root, options) {\n\treturn function(filename, directoryPath) {\n\t\tconst sameRoot = directoryPath.startsWith(root);\n\t\tif (sameRoot) return directoryPath.slice(root.length) + filename;\n\t\telse return convertSlashes((0, path.relative)(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;\n\t};\n}\nfunction joinPath(filename) {\n\treturn filename;\n}\nfunction joinDirectoryPath(filename, directoryPath, separator) {\n\treturn directoryPath + filename + separator;\n}\nfunction build$7(root, options) {\n\tconst { relativePaths, includeBasePath } = options;\n\treturn relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;\n}\n\n//#endregion\n//#region src/api/functions/push-directory.ts\nfunction pushDirectoryWithRelativePath(root) {\n\treturn function(directoryPath, paths) {\n\t\tpaths.push(directoryPath.substring(root.length) || \".\");\n\t};\n}\nfunction pushDirectoryFilterWithRelativePath(root) {\n\treturn function(directoryPath, paths, filters) {\n\t\tconst relativePath = directoryPath.substring(root.length) || \".\";\n\t\tif (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);\n\t};\n}\nconst pushDirectory = (directoryPath, paths) => {\n\tpaths.push(directoryPath || \".\");\n};\nconst pushDirectoryFilter = (directoryPath, paths, filters) => {\n\tconst path$1 = directoryPath || \".\";\n\tif (filters.every((filter) => filter(path$1, true))) paths.push(path$1);\n};\nconst empty$2 = () => {};\nfunction build$6(root, options) {\n\tconst { includeDirs, filters, relativePaths } = options;\n\tif (!includeDirs) return empty$2;\n\tif (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);\n\treturn filters && filters.length ? pushDirectoryFilter : pushDirectory;\n}\n\n//#endregion\n//#region src/api/functions/push-file.ts\nconst pushFileFilterAndCount = (filename, _paths, counts, filters) => {\n\tif (filters.every((filter) => filter(filename, false))) counts.files++;\n};\nconst pushFileFilter = (filename, paths, _counts, filters) => {\n\tif (filters.every((filter) => filter(filename, false))) paths.push(filename);\n};\nconst pushFileCount = (_filename, _paths, counts, _filters) => {\n\tcounts.files++;\n};\nconst pushFile = (filename, paths) => {\n\tpaths.push(filename);\n};\nconst empty$1 = () => {};\nfunction build$5(options) {\n\tconst { excludeFiles, filters, onlyCounts } = options;\n\tif (excludeFiles) return empty$1;\n\tif (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;\n\telse if (onlyCounts) return pushFileCount;\n\telse return pushFile;\n}\n\n//#endregion\n//#region src/api/functions/get-array.ts\nconst getArray = (paths) => {\n\treturn paths;\n};\nconst getArrayGroup = () => {\n\treturn [\"\"].slice(0, 0);\n};\nfunction build$4(options) {\n\treturn options.group ? getArrayGroup : getArray;\n}\n\n//#endregion\n//#region src/api/functions/group-files.ts\nconst groupFiles = (groups, directory, files) => {\n\tgroups.push({\n\t\tdirectory,\n\t\tfiles,\n\t\tdir: directory\n\t});\n};\nconst empty = () => {};\nfunction build$3(options) {\n\treturn options.group ? groupFiles : empty;\n}\n\n//#endregion\n//#region src/api/functions/resolve-symlink.ts\nconst resolveSymlinksAsync = function(path$1, state, callback$1) {\n\tconst { queue, fs: fs$1, options: { suppressErrors } } = state;\n\tqueue.enqueue();\n\tfs$1.realpath(path$1, (error, resolvedPath) => {\n\t\tif (error) return queue.dequeue(suppressErrors ? null : error, state);\n\t\tfs$1.stat(resolvedPath, (error$1, stat) => {\n\t\t\tif (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);\n\t\t\tif (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);\n\t\t\tcallback$1(stat, resolvedPath);\n\t\t\tqueue.dequeue(null, state);\n\t\t});\n\t});\n};\nconst resolveSymlinks = function(path$1, state, callback$1) {\n\tconst { queue, fs: fs$1, options: { suppressErrors } } = state;\n\tqueue.enqueue();\n\ttry {\n\t\tconst resolvedPath = fs$1.realpathSync(path$1);\n\t\tconst stat = fs$1.statSync(resolvedPath);\n\t\tif (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;\n\t\tcallback$1(stat, resolvedPath);\n\t} catch (e) {\n\t\tif (!suppressErrors) throw e;\n\t}\n};\nfunction build$2(options, isSynchronous) {\n\tif (!options.resolveSymlinks || options.excludeSymlinks) return null;\n\treturn isSynchronous ? resolveSymlinks : resolveSymlinksAsync;\n}\nfunction isRecursive(path$1, resolved, state) {\n\tif (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);\n\tlet parent = (0, path.dirname)(path$1);\n\tlet depth = 1;\n\twhile (parent !== state.root && depth < 2) {\n\t\tconst resolvedPath = state.symlinks.get(parent);\n\t\tconst isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));\n\t\tif (isSameRoot) depth++;\n\t\telse parent = (0, path.dirname)(parent);\n\t}\n\tstate.symlinks.set(path$1, resolved);\n\treturn depth > 1;\n}\nfunction isRecursiveUsingRealPaths(resolved, state) {\n\treturn state.visited.includes(resolved + state.options.pathSeparator);\n}\n\n//#endregion\n//#region src/api/functions/invoke-callback.ts\nconst onlyCountsSync = (state) => {\n\treturn state.counts;\n};\nconst groupsSync = (state) => {\n\treturn state.groups;\n};\nconst defaultSync = (state) => {\n\treturn state.paths;\n};\nconst limitFilesSync = (state) => {\n\treturn state.paths.slice(0, state.options.maxFiles);\n};\nconst onlyCountsAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.counts, state.options.suppressErrors);\n\treturn null;\n};\nconst defaultAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.paths, state.options.suppressErrors);\n\treturn null;\n};\nconst limitFilesAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);\n\treturn null;\n};\nconst groupsAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.groups, state.options.suppressErrors);\n\treturn null;\n};\nfunction report(error, callback$1, output, suppressErrors) {\n\tif (error && !suppressErrors) callback$1(error, output);\n\telse callback$1(null, output);\n}\nfunction build$1(options, isSynchronous) {\n\tconst { onlyCounts, group, maxFiles } = options;\n\tif (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;\n\telse if (group) return isSynchronous ? groupsSync : groupsAsync;\n\telse if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;\n\telse return isSynchronous ? defaultSync : defaultAsync;\n}\n\n//#endregion\n//#region src/api/functions/walk-directory.ts\nconst readdirOpts = { withFileTypes: true };\nconst walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {\n\tstate.queue.enqueue();\n\tif (currentDepth < 0) return state.queue.dequeue(null, state);\n\tconst { fs: fs$1 } = state;\n\tstate.visited.push(crawlPath);\n\tstate.counts.directories++;\n\tfs$1.readdir(crawlPath || \".\", readdirOpts, (error, entries = []) => {\n\t\tcallback$1(entries, directoryPath, currentDepth);\n\t\tstate.queue.dequeue(state.options.suppressErrors ? null : error, state);\n\t});\n};\nconst walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {\n\tconst { fs: fs$1 } = state;\n\tif (currentDepth < 0) return;\n\tstate.visited.push(crawlPath);\n\tstate.counts.directories++;\n\tlet entries = [];\n\ttry {\n\t\tentries = fs$1.readdirSync(crawlPath || \".\", readdirOpts);\n\t} catch (e) {\n\t\tif (!state.options.suppressErrors) throw e;\n\t}\n\tcallback$1(entries, directoryPath, currentDepth);\n};\nfunction build(isSynchronous) {\n\treturn isSynchronous ? walkSync : walkAsync;\n}\n\n//#endregion\n//#region src/api/queue.ts\n/**\n* This is a custom stateless queue to track concurrent async fs calls.\n* It increments a counter whenever a call is queued and decrements it\n* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.\n*/\nvar Queue = class {\n\tcount = 0;\n\tconstructor(onQueueEmpty) {\n\t\tthis.onQueueEmpty = onQueueEmpty;\n\t}\n\tenqueue() {\n\t\tthis.count++;\n\t\treturn this.count;\n\t}\n\tdequeue(error, output) {\n\t\tif (this.onQueueEmpty && (--this.count <= 0 || error)) {\n\t\t\tthis.onQueueEmpty(error, output);\n\t\t\tif (error) {\n\t\t\t\toutput.controller.abort();\n\t\t\t\tthis.onQueueEmpty = void 0;\n\t\t\t}\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/api/counter.ts\nvar Counter = class {\n\t_files = 0;\n\t_directories = 0;\n\tset files(num) {\n\t\tthis._files = num;\n\t}\n\tget files() {\n\t\treturn this._files;\n\t}\n\tset directories(num) {\n\t\tthis._directories = num;\n\t}\n\tget directories() {\n\t\treturn this._directories;\n\t}\n\t/**\n\t* @deprecated use `directories` instead\n\t*/\n\t/* c8 ignore next 3 */\n\tget dirs() {\n\t\treturn this._directories;\n\t}\n};\n\n//#endregion\n//#region src/api/aborter.ts\n/**\n* AbortController is not supported on Node 14 so we use this until we can drop\n* support for Node 14.\n*/\nvar Aborter = class {\n\taborted = false;\n\tabort() {\n\t\tthis.aborted = true;\n\t}\n};\n\n//#endregion\n//#region src/api/walker.ts\nvar Walker = class {\n\troot;\n\tisSynchronous;\n\tstate;\n\tjoinPath;\n\tpushDirectory;\n\tpushFile;\n\tgetArray;\n\tgroupFiles;\n\tresolveSymlink;\n\twalkDirectory;\n\tcallbackInvoker;\n\tconstructor(root, options, callback$1) {\n\t\tthis.isSynchronous = !callback$1;\n\t\tthis.callbackInvoker = build$1(options, this.isSynchronous);\n\t\tthis.root = normalizePath(root, options);\n\t\tthis.state = {\n\t\t\troot: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),\n\t\t\tpaths: [\"\"].slice(0, 0),\n\t\t\tgroups: [],\n\t\t\tcounts: new Counter(),\n\t\t\toptions,\n\t\t\tqueue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),\n\t\t\tsymlinks: /* @__PURE__ */ new Map(),\n\t\t\tvisited: [\"\"].slice(0, 0),\n\t\t\tcontroller: new Aborter(),\n\t\t\tfs: options.fs || fs\n\t\t};\n\t\tthis.joinPath = build$7(this.root, options);\n\t\tthis.pushDirectory = build$6(this.root, options);\n\t\tthis.pushFile = build$5(options);\n\t\tthis.getArray = build$4(options);\n\t\tthis.groupFiles = build$3(options);\n\t\tthis.resolveSymlink = build$2(options, this.isSynchronous);\n\t\tthis.walkDirectory = build(this.isSynchronous);\n\t}\n\tstart() {\n\t\tthis.pushDirectory(this.root, this.state.paths, this.state.options.filters);\n\t\tthis.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);\n\t\treturn this.isSynchronous ? this.callbackInvoker(this.state, null) : null;\n\t}\n\twalk = (entries, directoryPath, depth) => {\n\t\tconst { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;\n\t\tif (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;\n\t\tconst files = this.getArray(this.state.paths);\n\t\tfor (let i = 0; i < entries.length; ++i) {\n\t\t\tconst entry = entries[i];\n\t\t\tif (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {\n\t\t\t\tconst filename = this.joinPath(entry.name, directoryPath);\n\t\t\t\tthis.pushFile(filename, files, this.state.counts, filters);\n\t\t\t} else if (entry.isDirectory()) {\n\t\t\t\tlet path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);\n\t\t\t\tif (exclude && exclude(entry.name, path$1)) continue;\n\t\t\t\tthis.pushDirectory(path$1, paths, filters);\n\t\t\t\tthis.walkDirectory(this.state, path$1, path$1, depth - 1, this.walk);\n\t\t\t} else if (this.resolveSymlink && entry.isSymbolicLink()) {\n\t\t\t\tlet path$1 = joinPathWithBasePath(entry.name, directoryPath);\n\t\t\t\tthis.resolveSymlink(path$1, this.state, (stat, resolvedPath) => {\n\t\t\t\t\tif (stat.isDirectory()) {\n\t\t\t\t\t\tresolvedPath = normalizePath(resolvedPath, this.state.options);\n\t\t\t\t\t\tif (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;\n\t\t\t\t\t\tthis.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth - 1, this.walk);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolvedPath = useRealPaths ? resolvedPath : path$1;\n\t\t\t\t\t\tconst filename = (0, path.basename)(resolvedPath);\n\t\t\t\t\t\tconst directoryPath$1 = normalizePath((0, path.dirname)(resolvedPath), this.state.options);\n\t\t\t\t\t\tresolvedPath = this.joinPath(filename, directoryPath$1);\n\t\t\t\t\t\tthis.pushFile(resolvedPath, files, this.state.counts, filters);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis.groupFiles(this.state.groups, directoryPath, files);\n\t};\n};\n\n//#endregion\n//#region src/api/async.ts\nfunction promise(root, options) {\n\treturn new Promise((resolve$1, reject) => {\n\t\tcallback(root, options, (err, output) => {\n\t\t\tif (err) return reject(err);\n\t\t\tresolve$1(output);\n\t\t});\n\t});\n}\nfunction callback(root, options, callback$1) {\n\tlet walker = new Walker(root, options, callback$1);\n\twalker.start();\n}\n\n//#endregion\n//#region src/api/sync.ts\nfunction sync(root, options) {\n\tconst walker = new Walker(root, options);\n\treturn walker.start();\n}\n\n//#endregion\n//#region src/builder/api-builder.ts\nvar APIBuilder = class {\n\tconstructor(root, options) {\n\t\tthis.root = root;\n\t\tthis.options = options;\n\t}\n\twithPromise() {\n\t\treturn promise(this.root, this.options);\n\t}\n\twithCallback(cb) {\n\t\tcallback(this.root, this.options, cb);\n\t}\n\tsync() {\n\t\treturn sync(this.root, this.options);\n\t}\n};\n\n//#endregion\n//#region src/builder/index.ts\nlet pm = null;\n/* c8 ignore next 6 */\ntry {\n\trequire.resolve(\"picomatch\");\n\tpm = require(\"picomatch\");\n} catch {}\nvar Builder = class {\n\tglobCache = {};\n\toptions = {\n\t\tmaxDepth: Infinity,\n\t\tsuppressErrors: true,\n\t\tpathSeparator: path.sep,\n\t\tfilters: []\n\t};\n\tglobFunction;\n\tconstructor(options) {\n\t\tthis.options = {\n\t\t\t...this.options,\n\t\t\t...options\n\t\t};\n\t\tthis.globFunction = this.options.globFunction;\n\t}\n\tgroup() {\n\t\tthis.options.group = true;\n\t\treturn this;\n\t}\n\twithPathSeparator(separator) {\n\t\tthis.options.pathSeparator = separator;\n\t\treturn this;\n\t}\n\twithBasePath() {\n\t\tthis.options.includeBasePath = true;\n\t\treturn this;\n\t}\n\twithRelativePaths() {\n\t\tthis.options.relativePaths = true;\n\t\treturn this;\n\t}\n\twithDirs() {\n\t\tthis.options.includeDirs = true;\n\t\treturn this;\n\t}\n\twithMaxDepth(depth) {\n\t\tthis.options.maxDepth = depth;\n\t\treturn this;\n\t}\n\twithMaxFiles(limit) {\n\t\tthis.options.maxFiles = limit;\n\t\treturn this;\n\t}\n\twithFullPaths() {\n\t\tthis.options.resolvePaths = true;\n\t\tthis.options.includeBasePath = true;\n\t\treturn this;\n\t}\n\twithErrors() {\n\t\tthis.options.suppressErrors = false;\n\t\treturn this;\n\t}\n\twithSymlinks({ resolvePaths = true } = {}) {\n\t\tthis.options.resolveSymlinks = true;\n\t\tthis.options.useRealPaths = resolvePaths;\n\t\treturn this.withFullPaths();\n\t}\n\twithAbortSignal(signal) {\n\t\tthis.options.signal = signal;\n\t\treturn this;\n\t}\n\tnormalize() {\n\t\tthis.options.normalizePath = true;\n\t\treturn this;\n\t}\n\tfilter(predicate) {\n\t\tthis.options.filters.push(predicate);\n\t\treturn this;\n\t}\n\tonlyDirs() {\n\t\tthis.options.excludeFiles = true;\n\t\tthis.options.includeDirs = true;\n\t\treturn this;\n\t}\n\texclude(predicate) {\n\t\tthis.options.exclude = predicate;\n\t\treturn this;\n\t}\n\tonlyCounts() {\n\t\tthis.options.onlyCounts = true;\n\t\treturn this;\n\t}\n\tcrawl(root) {\n\t\treturn new APIBuilder(root || \".\", this.options);\n\t}\n\twithGlobFunction(fn) {\n\t\tthis.globFunction = fn;\n\t\treturn this;\n\t}\n\t/**\n\t* @deprecated Pass options using the constructor instead:\n\t* ```ts\n\t* new fdir(options).crawl(\"/path/to/root\");\n\t* ```\n\t* This method will be removed in v7.0\n\t*/\n\t/* c8 ignore next 4 */\n\tcrawlWithOptions(root, options) {\n\t\tthis.options = {\n\t\t\t...this.options,\n\t\t\t...options\n\t\t};\n\t\treturn new APIBuilder(root || \".\", this.options);\n\t}\n\tglob(...patterns) {\n\t\tif (this.globFunction) return this.globWithOptions(patterns);\n\t\treturn this.globWithOptions(patterns, ...[{ dot: true }]);\n\t}\n\tglobWithOptions(patterns, ...options) {\n\t\tconst globFn = this.globFunction || pm;\n\t\t/* c8 ignore next 5 */\n\t\tif (!globFn) throw new Error(\"Please specify a glob function to use glob matching.\");\n\t\tvar isMatch = this.globCache[patterns.join(\"\\0\")];\n\t\tif (!isMatch) {\n\t\t\tisMatch = globFn(patterns, ...options);\n\t\t\tthis.globCache[patterns.join(\"\\0\")] = isMatch;\n\t\t}\n\t\tthis.options.filters.push((path$1) => isMatch(path$1));\n\t\treturn this;\n\t}\n};\n\n//#endregion\nexports.fdir = Builder;"],"names":["require$$0","fs","require$$1","fs$1","require$$2"],"mappings":";;;;;;;;AACA,MAAI,WAAW,OAAO;AACtB,MAAI,YAAY,OAAO;AACvB,MAAI,mBAAmB,OAAO;AAC9B,MAAI,oBAAoB,OAAO;AAC/B,MAAI,eAAe,OAAO;AAC1B,MAAI,eAAe,OAAO,UAAU;AACpC,MAAI,cAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC7C,QAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,WAAY,UAAS,OAAO,kBAAkB,IAAI,GAAG,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK;AACrJ,YAAM,KAAK,CAAC;AACZ,UAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,OAAQ,WAAU,IAAI,KAAK;AAAA,QACrE,MAAM,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,MAAM,GAAG;AAAA,QACpC,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;AAAA,MAC7D,CAAG;AAAA,IACH;AACC,WAAO;AAAA,EACR;AACA,MAAI,UAAU,CAAC,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAA,GAAI,YAA0B,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;AAAA,IACrL,OAAO;AAAA,IACP,YAAY;AAAA,EACb,CAAC,IAAI,QAAQ,GAAG;AAGhB,QAAM,OAAO,QAAQA,aAAe;AACpC,QAAMC,OAAK,QAAQC,EAAa;AAGhC,WAAS,UAAU,QAAQ;AAC1B,QAAI,cAAa,GAAI,KAAK,WAAW,MAAM;AAC3C,QAAI,WAAW,SAAS,KAAK,WAAW,WAAW,SAAS,CAAC,MAAM,KAAK,IAAK,cAA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aAAO,KAAK,gBAAgB,UAAU,GAAG,CAAC,EAAE,KAAK,KAAI,CAAE,CAAC;AAAA,IAC1D;AAAA,IACC,gBAAgB,aAAa,SAAS;AACrC,YAAM,SAAS,KAAK,gBAAgB;AAEpC,UAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,sDAAsD;AACnF,UAAI,UAAU,KAAK,UAAU,SAAS,KAAK,IAAI,CAAC;AAChD,UAAI,CAAC,SAAS;AACb,kBAAU,OAAO,UAAU,GAAG,OAAO;AACrC,aAAK,UAAU,SAAS,KAAK,IAAI,CAAC,IAAI;AAAA,MACzC;AACE,WAAK,QAAQ,QAAQ,KAAK,CAAC,WAAW,QAAQ,MAAM,CAAC;AACrD,aAAO;AAAA,IACT;AAAA;AAIA,OAAA,OAAe;;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../node_modules/fdir/dist/index.cjs"],"sourcesContent":["//#region rolldown:runtime\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {\n\t\tkey = keys[i];\n\t\tif (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: ((k) => from[k]).bind(null, key),\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", {\n\tvalue: mod,\n\tenumerable: true\n}) : target, mod));\n\n//#endregion\nconst path = __toESM(require(\"path\"));\nconst fs = __toESM(require(\"fs\"));\n\n//#region src/utils.ts\nfunction cleanPath(path$1) {\n\tlet normalized = (0, path.normalize)(path$1);\n\tif (normalized.length > 1 && normalized[normalized.length - 1] === path.sep) normalized = normalized.substring(0, normalized.length - 1);\n\treturn normalized;\n}\nconst SLASHES_REGEX = /[\\\\/]/g;\nfunction convertSlashes(path$1, separator) {\n\treturn path$1.replace(SLASHES_REGEX, separator);\n}\nconst WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\\\/]$/i;\nfunction isRootDirectory(path$1) {\n\treturn path$1 === \"/\" || WINDOWS_ROOT_DIR_REGEX.test(path$1);\n}\nfunction normalizePath(path$1, options) {\n\tconst { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;\n\tconst pathNeedsCleaning = process.platform === \"win32\" && path$1.includes(\"/\") || path$1.startsWith(\".\");\n\tif (resolvePaths) path$1 = (0, path.resolve)(path$1);\n\tif (normalizePath$1 || pathNeedsCleaning) path$1 = cleanPath(path$1);\n\tif (path$1 === \".\") return \"\";\n\tconst needsSeperator = path$1[path$1.length - 1] !== pathSeparator;\n\treturn convertSlashes(needsSeperator ? path$1 + pathSeparator : path$1, pathSeparator);\n}\n\n//#endregion\n//#region src/api/functions/join-path.ts\nfunction joinPathWithBasePath(filename, directoryPath) {\n\treturn directoryPath + filename;\n}\nfunction joinPathWithRelativePath(root, options) {\n\treturn function(filename, directoryPath) {\n\t\tconst sameRoot = directoryPath.startsWith(root);\n\t\tif (sameRoot) return directoryPath.slice(root.length) + filename;\n\t\telse return convertSlashes((0, path.relative)(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;\n\t};\n}\nfunction joinPath(filename) {\n\treturn filename;\n}\nfunction joinDirectoryPath(filename, directoryPath, separator) {\n\treturn directoryPath + filename + separator;\n}\nfunction build$7(root, options) {\n\tconst { relativePaths, includeBasePath } = options;\n\treturn relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;\n}\n\n//#endregion\n//#region src/api/functions/push-directory.ts\nfunction pushDirectoryWithRelativePath(root) {\n\treturn function(directoryPath, paths) {\n\t\tpaths.push(directoryPath.substring(root.length) || \".\");\n\t};\n}\nfunction pushDirectoryFilterWithRelativePath(root) {\n\treturn function(directoryPath, paths, filters) {\n\t\tconst relativePath = directoryPath.substring(root.length) || \".\";\n\t\tif (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);\n\t};\n}\nconst pushDirectory = (directoryPath, paths) => {\n\tpaths.push(directoryPath || \".\");\n};\nconst pushDirectoryFilter = (directoryPath, paths, filters) => {\n\tconst path$1 = directoryPath || \".\";\n\tif (filters.every((filter) => filter(path$1, true))) paths.push(path$1);\n};\nconst empty$2 = () => {};\nfunction build$6(root, options) {\n\tconst { includeDirs, filters, relativePaths } = options;\n\tif (!includeDirs) return empty$2;\n\tif (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);\n\treturn filters && filters.length ? pushDirectoryFilter : pushDirectory;\n}\n\n//#endregion\n//#region src/api/functions/push-file.ts\nconst pushFileFilterAndCount = (filename, _paths, counts, filters) => {\n\tif (filters.every((filter) => filter(filename, false))) counts.files++;\n};\nconst pushFileFilter = (filename, paths, _counts, filters) => {\n\tif (filters.every((filter) => filter(filename, false))) paths.push(filename);\n};\nconst pushFileCount = (_filename, _paths, counts, _filters) => {\n\tcounts.files++;\n};\nconst pushFile = (filename, paths) => {\n\tpaths.push(filename);\n};\nconst empty$1 = () => {};\nfunction build$5(options) {\n\tconst { excludeFiles, filters, onlyCounts } = options;\n\tif (excludeFiles) return empty$1;\n\tif (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;\n\telse if (onlyCounts) return pushFileCount;\n\telse return pushFile;\n}\n\n//#endregion\n//#region src/api/functions/get-array.ts\nconst getArray = (paths) => {\n\treturn paths;\n};\nconst getArrayGroup = () => {\n\treturn [\"\"].slice(0, 0);\n};\nfunction build$4(options) {\n\treturn options.group ? getArrayGroup : getArray;\n}\n\n//#endregion\n//#region src/api/functions/group-files.ts\nconst groupFiles = (groups, directory, files) => {\n\tgroups.push({\n\t\tdirectory,\n\t\tfiles,\n\t\tdir: directory\n\t});\n};\nconst empty = () => {};\nfunction build$3(options) {\n\treturn options.group ? groupFiles : empty;\n}\n\n//#endregion\n//#region src/api/functions/resolve-symlink.ts\nconst resolveSymlinksAsync = function(path$1, state, callback$1) {\n\tconst { queue, fs: fs$1, options: { suppressErrors } } = state;\n\tqueue.enqueue();\n\tfs$1.realpath(path$1, (error, resolvedPath) => {\n\t\tif (error) return queue.dequeue(suppressErrors ? null : error, state);\n\t\tfs$1.stat(resolvedPath, (error$1, stat) => {\n\t\t\tif (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);\n\t\t\tif (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);\n\t\t\tcallback$1(stat, resolvedPath);\n\t\t\tqueue.dequeue(null, state);\n\t\t});\n\t});\n};\nconst resolveSymlinks = function(path$1, state, callback$1) {\n\tconst { queue, fs: fs$1, options: { suppressErrors } } = state;\n\tqueue.enqueue();\n\ttry {\n\t\tconst resolvedPath = fs$1.realpathSync(path$1);\n\t\tconst stat = fs$1.statSync(resolvedPath);\n\t\tif (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;\n\t\tcallback$1(stat, resolvedPath);\n\t} catch (e) {\n\t\tif (!suppressErrors) throw e;\n\t}\n};\nfunction build$2(options, isSynchronous) {\n\tif (!options.resolveSymlinks || options.excludeSymlinks) return null;\n\treturn isSynchronous ? resolveSymlinks : resolveSymlinksAsync;\n}\nfunction isRecursive(path$1, resolved, state) {\n\tif (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);\n\tlet parent = (0, path.dirname)(path$1);\n\tlet depth = 1;\n\twhile (parent !== state.root && depth < 2) {\n\t\tconst resolvedPath = state.symlinks.get(parent);\n\t\tconst isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));\n\t\tif (isSameRoot) depth++;\n\t\telse parent = (0, path.dirname)(parent);\n\t}\n\tstate.symlinks.set(path$1, resolved);\n\treturn depth > 1;\n}\nfunction isRecursiveUsingRealPaths(resolved, state) {\n\treturn state.visited.includes(resolved + state.options.pathSeparator);\n}\n\n//#endregion\n//#region src/api/functions/invoke-callback.ts\nconst onlyCountsSync = (state) => {\n\treturn state.counts;\n};\nconst groupsSync = (state) => {\n\treturn state.groups;\n};\nconst defaultSync = (state) => {\n\treturn state.paths;\n};\nconst limitFilesSync = (state) => {\n\treturn state.paths.slice(0, state.options.maxFiles);\n};\nconst onlyCountsAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.counts, state.options.suppressErrors);\n\treturn null;\n};\nconst defaultAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.paths, state.options.suppressErrors);\n\treturn null;\n};\nconst limitFilesAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);\n\treturn null;\n};\nconst groupsAsync = (state, error, callback$1) => {\n\treport(error, callback$1, state.groups, state.options.suppressErrors);\n\treturn null;\n};\nfunction report(error, callback$1, output, suppressErrors) {\n\tif (error && !suppressErrors) callback$1(error, output);\n\telse callback$1(null, output);\n}\nfunction build$1(options, isSynchronous) {\n\tconst { onlyCounts, group, maxFiles } = options;\n\tif (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;\n\telse if (group) return isSynchronous ? groupsSync : groupsAsync;\n\telse if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;\n\telse return isSynchronous ? defaultSync : defaultAsync;\n}\n\n//#endregion\n//#region src/api/functions/walk-directory.ts\nconst readdirOpts = { withFileTypes: true };\nconst walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {\n\tstate.queue.enqueue();\n\tif (currentDepth < 0) return state.queue.dequeue(null, state);\n\tconst { fs: fs$1 } = state;\n\tstate.visited.push(crawlPath);\n\tstate.counts.directories++;\n\tfs$1.readdir(crawlPath || \".\", readdirOpts, (error, entries = []) => {\n\t\tcallback$1(entries, directoryPath, currentDepth);\n\t\tstate.queue.dequeue(state.options.suppressErrors ? null : error, state);\n\t});\n};\nconst walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {\n\tconst { fs: fs$1 } = state;\n\tif (currentDepth < 0) return;\n\tstate.visited.push(crawlPath);\n\tstate.counts.directories++;\n\tlet entries = [];\n\ttry {\n\t\tentries = fs$1.readdirSync(crawlPath || \".\", readdirOpts);\n\t} catch (e) {\n\t\tif (!state.options.suppressErrors) throw e;\n\t}\n\tcallback$1(entries, directoryPath, currentDepth);\n};\nfunction build(isSynchronous) {\n\treturn isSynchronous ? walkSync : walkAsync;\n}\n\n//#endregion\n//#region src/api/queue.ts\n/**\n* This is a custom stateless queue to track concurrent async fs calls.\n* It increments a counter whenever a call is queued and decrements it\n* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.\n*/\nvar Queue = class {\n\tcount = 0;\n\tconstructor(onQueueEmpty) {\n\t\tthis.onQueueEmpty = onQueueEmpty;\n\t}\n\tenqueue() {\n\t\tthis.count++;\n\t\treturn this.count;\n\t}\n\tdequeue(error, output) {\n\t\tif (this.onQueueEmpty && (--this.count <= 0 || error)) {\n\t\t\tthis.onQueueEmpty(error, output);\n\t\t\tif (error) {\n\t\t\t\toutput.controller.abort();\n\t\t\t\tthis.onQueueEmpty = void 0;\n\t\t\t}\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/api/counter.ts\nvar Counter = class {\n\t_files = 0;\n\t_directories = 0;\n\tset files(num) {\n\t\tthis._files = num;\n\t}\n\tget files() {\n\t\treturn this._files;\n\t}\n\tset directories(num) {\n\t\tthis._directories = num;\n\t}\n\tget directories() {\n\t\treturn this._directories;\n\t}\n\t/**\n\t* @deprecated use `directories` instead\n\t*/\n\t/* c8 ignore next 3 */\n\tget dirs() {\n\t\treturn this._directories;\n\t}\n};\n\n//#endregion\n//#region src/api/aborter.ts\n/**\n* AbortController is not supported on Node 14 so we use this until we can drop\n* support for Node 14.\n*/\nvar Aborter = class {\n\taborted = false;\n\tabort() {\n\t\tthis.aborted = true;\n\t}\n};\n\n//#endregion\n//#region src/api/walker.ts\nvar Walker = class {\n\troot;\n\tisSynchronous;\n\tstate;\n\tjoinPath;\n\tpushDirectory;\n\tpushFile;\n\tgetArray;\n\tgroupFiles;\n\tresolveSymlink;\n\twalkDirectory;\n\tcallbackInvoker;\n\tconstructor(root, options, callback$1) {\n\t\tthis.isSynchronous = !callback$1;\n\t\tthis.callbackInvoker = build$1(options, this.isSynchronous);\n\t\tthis.root = normalizePath(root, options);\n\t\tthis.state = {\n\t\t\troot: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),\n\t\t\tpaths: [\"\"].slice(0, 0),\n\t\t\tgroups: [],\n\t\t\tcounts: new Counter(),\n\t\t\toptions,\n\t\t\tqueue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),\n\t\t\tsymlinks: /* @__PURE__ */ new Map(),\n\t\t\tvisited: [\"\"].slice(0, 0),\n\t\t\tcontroller: new Aborter(),\n\t\t\tfs: options.fs || fs\n\t\t};\n\t\tthis.joinPath = build$7(this.root, options);\n\t\tthis.pushDirectory = build$6(this.root, options);\n\t\tthis.pushFile = build$5(options);\n\t\tthis.getArray = build$4(options);\n\t\tthis.groupFiles = build$3(options);\n\t\tthis.resolveSymlink = build$2(options, this.isSynchronous);\n\t\tthis.walkDirectory = build(this.isSynchronous);\n\t}\n\tstart() {\n\t\tthis.pushDirectory(this.root, this.state.paths, this.state.options.filters);\n\t\tthis.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);\n\t\treturn this.isSynchronous ? this.callbackInvoker(this.state, null) : null;\n\t}\n\twalk = (entries, directoryPath, depth) => {\n\t\tconst { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;\n\t\tif (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;\n\t\tconst files = this.getArray(this.state.paths);\n\t\tfor (let i = 0; i < entries.length; ++i) {\n\t\t\tconst entry = entries[i];\n\t\t\tif (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {\n\t\t\t\tconst filename = this.joinPath(entry.name, directoryPath);\n\t\t\t\tthis.pushFile(filename, files, this.state.counts, filters);\n\t\t\t} else if (entry.isDirectory()) {\n\t\t\t\tlet path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);\n\t\t\t\tif (exclude && exclude(entry.name, path$1)) continue;\n\t\t\t\tthis.pushDirectory(path$1, paths, filters);\n\t\t\t\tthis.walkDirectory(this.state, path$1, path$1, depth - 1, this.walk);\n\t\t\t} else if (this.resolveSymlink && entry.isSymbolicLink()) {\n\t\t\t\tlet path$1 = joinPathWithBasePath(entry.name, directoryPath);\n\t\t\t\tthis.resolveSymlink(path$1, this.state, (stat, resolvedPath) => {\n\t\t\t\t\tif (stat.isDirectory()) {\n\t\t\t\t\t\tresolvedPath = normalizePath(resolvedPath, this.state.options);\n\t\t\t\t\t\tif (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;\n\t\t\t\t\t\tthis.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth - 1, this.walk);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tresolvedPath = useRealPaths ? resolvedPath : path$1;\n\t\t\t\t\t\tconst filename = (0, path.basename)(resolvedPath);\n\t\t\t\t\t\tconst directoryPath$1 = normalizePath((0, path.dirname)(resolvedPath), this.state.options);\n\t\t\t\t\t\tresolvedPath = this.joinPath(filename, directoryPath$1);\n\t\t\t\t\t\tthis.pushFile(resolvedPath, files, this.state.counts, filters);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tthis.groupFiles(this.state.groups, directoryPath, files);\n\t};\n};\n\n//#endregion\n//#region src/api/async.ts\nfunction promise(root, options) {\n\treturn new Promise((resolve$1, reject) => {\n\t\tcallback(root, options, (err, output) => {\n\t\t\tif (err) return reject(err);\n\t\t\tresolve$1(output);\n\t\t});\n\t});\n}\nfunction callback(root, options, callback$1) {\n\tlet walker = new Walker(root, options, callback$1);\n\twalker.start();\n}\n\n//#endregion\n//#region src/api/sync.ts\nfunction sync(root, options) {\n\tconst walker = new Walker(root, options);\n\treturn walker.start();\n}\n\n//#endregion\n//#region src/builder/api-builder.ts\nvar APIBuilder = class {\n\tconstructor(root, options) {\n\t\tthis.root = root;\n\t\tthis.options = options;\n\t}\n\twithPromise() {\n\t\treturn promise(this.root, this.options);\n\t}\n\twithCallback(cb) {\n\t\tcallback(this.root, this.options, cb);\n\t}\n\tsync() {\n\t\treturn sync(this.root, this.options);\n\t}\n};\n\n//#endregion\n//#region src/builder/index.ts\nlet pm = null;\n/* c8 ignore next 6 */\ntry {\n\trequire.resolve(\"picomatch\");\n\tpm = require(\"picomatch\");\n} catch {}\nvar Builder = class {\n\tglobCache = {};\n\toptions = {\n\t\tmaxDepth: Infinity,\n\t\tsuppressErrors: true,\n\t\tpathSeparator: path.sep,\n\t\tfilters: []\n\t};\n\tglobFunction;\n\tconstructor(options) {\n\t\tthis.options = {\n\t\t\t...this.options,\n\t\t\t...options\n\t\t};\n\t\tthis.globFunction = this.options.globFunction;\n\t}\n\tgroup() {\n\t\tthis.options.group = true;\n\t\treturn this;\n\t}\n\twithPathSeparator(separator) {\n\t\tthis.options.pathSeparator = separator;\n\t\treturn this;\n\t}\n\twithBasePath() {\n\t\tthis.options.includeBasePath = true;\n\t\treturn this;\n\t}\n\twithRelativePaths() {\n\t\tthis.options.relativePaths = true;\n\t\treturn this;\n\t}\n\twithDirs() {\n\t\tthis.options.includeDirs = true;\n\t\treturn this;\n\t}\n\twithMaxDepth(depth) {\n\t\tthis.options.maxDepth = depth;\n\t\treturn this;\n\t}\n\twithMaxFiles(limit) {\n\t\tthis.options.maxFiles = limit;\n\t\treturn this;\n\t}\n\twithFullPaths() {\n\t\tthis.options.resolvePaths = true;\n\t\tthis.options.includeBasePath = true;\n\t\treturn this;\n\t}\n\twithErrors() {\n\t\tthis.options.suppressErrors = false;\n\t\treturn this;\n\t}\n\twithSymlinks({ resolvePaths = true } = {}) {\n\t\tthis.options.resolveSymlinks = true;\n\t\tthis.options.useRealPaths = resolvePaths;\n\t\treturn this.withFullPaths();\n\t}\n\twithAbortSignal(signal) {\n\t\tthis.options.signal = signal;\n\t\treturn this;\n\t}\n\tnormalize() {\n\t\tthis.options.normalizePath = true;\n\t\treturn this;\n\t}\n\tfilter(predicate) {\n\t\tthis.options.filters.push(predicate);\n\t\treturn this;\n\t}\n\tonlyDirs() {\n\t\tthis.options.excludeFiles = true;\n\t\tthis.options.includeDirs = true;\n\t\treturn this;\n\t}\n\texclude(predicate) {\n\t\tthis.options.exclude = predicate;\n\t\treturn this;\n\t}\n\tonlyCounts() {\n\t\tthis.options.onlyCounts = true;\n\t\treturn this;\n\t}\n\tcrawl(root) {\n\t\treturn new APIBuilder(root || \".\", this.options);\n\t}\n\twithGlobFunction(fn) {\n\t\tthis.globFunction = fn;\n\t\treturn this;\n\t}\n\t/**\n\t* @deprecated Pass options using the constructor instead:\n\t* ```ts\n\t* new fdir(options).crawl(\"/path/to/root\");\n\t* ```\n\t* This method will be removed in v7.0\n\t*/\n\t/* c8 ignore next 4 */\n\tcrawlWithOptions(root, options) {\n\t\tthis.options = {\n\t\t\t...this.options,\n\t\t\t...options\n\t\t};\n\t\treturn new APIBuilder(root || \".\", this.options);\n\t}\n\tglob(...patterns) {\n\t\tif (this.globFunction) return this.globWithOptions(patterns);\n\t\treturn this.globWithOptions(patterns, ...[{ dot: true }]);\n\t}\n\tglobWithOptions(patterns, ...options) {\n\t\tconst globFn = this.globFunction || pm;\n\t\t/* c8 ignore next 5 */\n\t\tif (!globFn) throw new Error(\"Please specify a glob function to use glob matching.\");\n\t\tvar isMatch = this.globCache[patterns.join(\"\\0\")];\n\t\tif (!isMatch) {\n\t\t\tisMatch = globFn(patterns, ...options);\n\t\t\tthis.globCache[patterns.join(\"\\0\")] = isMatch;\n\t\t}\n\t\tthis.options.filters.push((path$1) => isMatch(path$1));\n\t\treturn this;\n\t}\n};\n\n//#endregion\nexports.fdir = Builder;"],"names":["require$$0","require$$2"],"mappings":";;;;;;;;AACA,MAAI,WAAW,OAAO;AACtB,MAAI,YAAY,OAAO;AACvB,MAAI,mBAAmB,OAAO;AAC9B,MAAI,oBAAoB,OAAO;AAC/B,MAAI,eAAe,OAAO;AAC1B,MAAI,eAAe,OAAO,UAAU;AACpC,MAAI,cAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC7C,QAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,WAAY,UAAS,OAAO,kBAAkB,IAAI,GAAG,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK;AACrJ,YAAM,KAAK,CAAC;AACZ,UAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,OAAQ,WAAU,IAAI,KAAK;AAAA,QACrE,MAAM,CAAC,MAAM,KAAK,CAAC,GAAG,KAAK,MAAM,GAAG;AAAA,QACpC,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;AAAA,MAC7D,CAAG;AAAA,IACH;AACC,WAAO;AAAA,EACR;AACA,MAAI,UAAU,CAAC,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAA,GAAI,YAA0B,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;AAAA,IACrL,OAAO;AAAA,IACP,YAAY;AAAA,EACb,CAAC,IAAI,QAAQ,GAAG;AAGhB,QAAM,OAAO,QAAQA,aAAe;AACpC,QAAM,KAAK,QAAQ,UAAa;AAGhC,WAAS,UAAU,QAAQ;AAC1B,QAAI,cAAa,GAAI,KAAK,WAAW,MAA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