agent-ide 0.13.6 → 0.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.d.ts +11 -2
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.d.ts.map +1 -1
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.js +233 -25
- package/dist/core/call-hierarchy/call-hierarchy-analyzer.js.map +1 -1
- package/dist/core/change-signature/call-site-updater.d.ts +0 -1
- package/dist/core/change-signature/call-site-updater.d.ts.map +1 -1
- package/dist/core/change-signature/call-site-updater.js +0 -2
- package/dist/core/change-signature/call-site-updater.js.map +1 -1
- package/dist/core/change-signature/change-signature-engine.d.ts +9 -1
- package/dist/core/change-signature/change-signature-engine.d.ts.map +1 -1
- package/dist/core/change-signature/change-signature-engine.js +190 -5
- package/dist/core/change-signature/change-signature-engine.js.map +1 -1
- package/dist/core/change-signature/signature-parser.d.ts +0 -5
- package/dist/core/change-signature/signature-parser.d.ts.map +1 -1
- package/dist/core/change-signature/signature-parser.js +6 -34
- package/dist/core/change-signature/signature-parser.js.map +1 -1
- package/dist/core/deadcode/file-operations.d.ts.map +1 -1
- package/dist/core/deadcode/file-operations.js +3 -1
- package/dist/core/deadcode/file-operations.js.map +1 -1
- package/dist/core/deadcode/import-cleaner.d.ts.map +1 -1
- package/dist/core/deadcode/import-cleaner.js +3 -1
- package/dist/core/deadcode/import-cleaner.js.map +1 -1
- package/dist/core/deadcode/range-expander.d.ts +9 -1
- package/dist/core/deadcode/range-expander.d.ts.map +1 -1
- package/dist/core/deadcode/range-expander.js +115 -41
- package/dist/core/deadcode/range-expander.js.map +1 -1
- package/dist/core/foundations/file-utils.d.ts.map +1 -1
- package/dist/core/foundations/file-utils.js +6 -3
- package/dist/core/foundations/file-utils.js.map +1 -1
- package/dist/core/foundations/indexing/file-index.d.ts +5 -2
- package/dist/core/foundations/indexing/file-index.d.ts.map +1 -1
- package/dist/core/foundations/indexing/file-index.js +11 -3
- package/dist/core/foundations/indexing/file-index.js.map +1 -1
- package/dist/core/foundations/indexing/index-cache-serializer.d.ts +133 -0
- package/dist/core/foundations/indexing/index-cache-serializer.d.ts.map +1 -0
- package/dist/core/foundations/indexing/index-cache-serializer.js +217 -0
- package/dist/core/foundations/indexing/index-cache-serializer.js.map +1 -0
- package/dist/core/foundations/indexing/index-engine.d.ts +11 -5
- package/dist/core/foundations/indexing/index-engine.d.ts.map +1 -1
- package/dist/core/foundations/indexing/index-engine.js +31 -22
- package/dist/core/foundations/indexing/index-engine.js.map +1 -1
- package/dist/core/foundations/indexing/index.d.ts +4 -1
- package/dist/core/foundations/indexing/index.d.ts.map +1 -1
- package/dist/core/foundations/indexing/index.js +2 -1
- package/dist/core/foundations/indexing/index.js.map +1 -1
- package/dist/core/foundations/indexing/symbol-index.d.ts +7 -1
- package/dist/core/foundations/indexing/symbol-index.d.ts.map +1 -1
- package/dist/core/foundations/indexing/symbol-index.js +54 -3
- package/dist/core/foundations/indexing/symbol-index.js.map +1 -1
- package/dist/core/foundations/indexing/types.d.ts +3 -2
- package/dist/core/foundations/indexing/types.d.ts.map +1 -1
- package/dist/core/foundations/indexing/types.js +8 -6
- package/dist/core/foundations/indexing/types.js.map +1 -1
- package/dist/core/foundations/symbol-finder/call-site-parser.d.ts.map +1 -1
- package/dist/core/foundations/symbol-finder/call-site-parser.js +3 -1
- package/dist/core/foundations/symbol-finder/call-site-parser.js.map +1 -1
- package/dist/core/foundations/symbol-finder/symbol-finder.d.ts +0 -2
- package/dist/core/foundations/symbol-finder/symbol-finder.d.ts.map +1 -1
- package/dist/core/foundations/symbol-finder/symbol-finder.js +15 -11
- package/dist/core/foundations/symbol-finder/symbol-finder.js.map +1 -1
- package/dist/core/impact/dependency-extractor.d.ts +11 -3
- package/dist/core/impact/dependency-extractor.d.ts.map +1 -1
- package/dist/core/impact/dependency-extractor.js +149 -34
- package/dist/core/impact/dependency-extractor.js.map +1 -1
- package/dist/core/impact/file-scanner.d.ts.map +1 -1
- package/dist/core/impact/file-scanner.js +3 -2
- package/dist/core/impact/file-scanner.js.map +1 -1
- package/dist/core/impact/impact-analyzer.d.ts +8 -1
- package/dist/core/impact/impact-analyzer.d.ts.map +1 -1
- package/dist/core/impact/impact-analyzer.js +27 -8
- package/dist/core/impact/impact-analyzer.js.map +1 -1
- package/dist/core/impact/path-resolver.d.ts.map +1 -1
- package/dist/core/impact/path-resolver.js +11 -10
- package/dist/core/impact/path-resolver.js.map +1 -1
- package/dist/core/impact/types.d.ts.map +1 -1
- package/dist/core/impact/types.js +2 -1
- package/dist/core/impact/types.js.map +1 -1
- package/dist/core/move/file-scanner.d.ts +12 -0
- package/dist/core/move/file-scanner.d.ts.map +1 -1
- package/dist/core/move/file-scanner.js +58 -30
- package/dist/core/move/file-scanner.js.map +1 -1
- package/dist/core/move/glob-move-planner.d.ts +29 -0
- package/dist/core/move/glob-move-planner.d.ts.map +1 -0
- package/dist/core/move/glob-move-planner.js +48 -0
- package/dist/core/move/glob-move-planner.js.map +1 -0
- package/dist/core/move/index.d.ts +2 -0
- package/dist/core/move/index.d.ts.map +1 -1
- package/dist/core/move/index.js +1 -0
- package/dist/core/move/index.js.map +1 -1
- package/dist/core/move/move-engine.js +2 -2
- package/dist/core/move/move-engine.js.map +1 -1
- package/dist/core/move/path-calculator.d.ts +2 -0
- package/dist/core/move/path-calculator.d.ts.map +1 -1
- package/dist/core/move/path-calculator.js +36 -16
- package/dist/core/move/path-calculator.js.map +1 -1
- package/dist/core/move/path-utils.d.ts +2 -1
- package/dist/core/move/path-utils.d.ts.map +1 -1
- package/dist/core/move/path-utils.js +18 -28
- package/dist/core/move/path-utils.js.map +1 -1
- package/dist/core/move-member/change-applier.d.ts.map +1 -1
- package/dist/core/move-member/change-applier.js +3 -1
- package/dist/core/move-member/change-applier.js.map +1 -1
- package/dist/core/move-member/extractors/typescript-extractor.d.ts.map +1 -1
- package/dist/core/move-member/extractors/typescript-extractor.js +32 -28
- package/dist/core/move-member/extractors/typescript-extractor.js.map +1 -1
- package/dist/core/move-member/file-change-preparer.d.ts +5 -0
- package/dist/core/move-member/file-change-preparer.d.ts.map +1 -1
- package/dist/core/move-member/file-change-preparer.js +51 -11
- package/dist/core/move-member/file-change-preparer.js.map +1 -1
- package/dist/core/move-member/member-extractor.d.ts +0 -2
- package/dist/core/move-member/member-extractor.d.ts.map +1 -1
- package/dist/core/move-member/member-extractor.js +13 -22
- package/dist/core/move-member/member-extractor.js.map +1 -1
- package/dist/core/move-member/move-member-engine.d.ts +0 -1
- package/dist/core/move-member/move-member-engine.d.ts.map +1 -1
- package/dist/core/move-member/move-member-engine.js +0 -2
- package/dist/core/move-member/move-member-engine.js.map +1 -1
- package/dist/core/move-member/reference-updater.d.ts.map +1 -1
- package/dist/core/move-member/reference-updater.js +7 -10
- package/dist/core/move-member/reference-updater.js.map +1 -1
- package/dist/core/rename/reference-updater.d.ts +1 -0
- package/dist/core/rename/reference-updater.d.ts.map +1 -1
- package/dist/core/rename/reference-updater.js +48 -46
- package/dist/core/rename/reference-updater.js.map +1 -1
- package/dist/core/rename/rename-engine.d.ts +0 -1
- package/dist/core/rename/rename-engine.d.ts.map +1 -1
- package/dist/core/rename/rename-engine.js +9 -22
- package/dist/core/rename/rename-engine.js.map +1 -1
- package/dist/infrastructure/cache/cache-manager.d.ts.map +1 -1
- package/dist/infrastructure/cache/cache-manager.js +4 -5
- package/dist/infrastructure/cache/cache-manager.js.map +1 -1
- package/dist/infrastructure/cache/index-disk-cache.d.ts +46 -0
- package/dist/infrastructure/cache/index-disk-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/index-disk-cache.js +150 -0
- package/dist/infrastructure/cache/index-disk-cache.js.map +1 -0
- package/dist/infrastructure/cache/index.d.ts.map +1 -1
- package/dist/infrastructure/cache/index.js +1 -0
- package/dist/infrastructure/cache/index.js.map +1 -1
- package/dist/infrastructure/cache/memory-cache.d.ts.map +1 -1
- package/dist/infrastructure/cache/memory-cache.js +3 -1
- package/dist/infrastructure/cache/memory-cache.js.map +1 -1
- package/dist/infrastructure/formatters/index.d.ts +1 -2
- package/dist/infrastructure/formatters/index.d.ts.map +1 -1
- package/dist/infrastructure/formatters/index.js +1 -2
- package/dist/infrastructure/formatters/index.js.map +1 -1
- package/dist/infrastructure/formatters/query-formatter.d.ts.map +1 -1
- package/dist/infrastructure/formatters/query-formatter.js +9 -18
- package/dist/infrastructure/formatters/query-formatter.js.map +1 -1
- package/dist/infrastructure/formatters/query-types.d.ts +15 -145
- package/dist/infrastructure/formatters/query-types.d.ts.map +1 -1
- package/dist/infrastructure/formatters/query-types.js +3 -18
- package/dist/infrastructure/formatters/query-types.js.map +1 -1
- package/dist/infrastructure/formatters/strategies/base-formatter.d.ts +1 -20
- package/dist/infrastructure/formatters/strategies/base-formatter.d.ts.map +1 -1
- package/dist/infrastructure/formatters/strategies/base-formatter.js +0 -8
- package/dist/infrastructure/formatters/strategies/base-formatter.js.map +1 -1
- package/dist/infrastructure/formatters/strategies/call-hierarchy-formatter.d.ts.map +1 -1
- package/dist/infrastructure/formatters/strategies/call-hierarchy-formatter.js +7 -0
- package/dist/infrastructure/formatters/strategies/call-hierarchy-formatter.js.map +1 -1
- package/dist/infrastructure/formatters/strategies/cycles-formatter.d.ts +15 -0
- package/dist/infrastructure/formatters/strategies/cycles-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/cycles-formatter.js +29 -0
- package/dist/infrastructure/formatters/strategies/cycles-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/impact-formatter.d.ts +15 -0
- package/dist/infrastructure/formatters/strategies/impact-formatter.d.ts.map +1 -0
- package/dist/infrastructure/formatters/strategies/impact-formatter.js +31 -0
- package/dist/infrastructure/formatters/strategies/impact-formatter.js.map +1 -0
- package/dist/infrastructure/formatters/strategies/index.d.ts +3 -4
- package/dist/infrastructure/formatters/strategies/index.d.ts.map +1 -1
- package/dist/infrastructure/formatters/strategies/index.js +3 -4
- package/dist/infrastructure/formatters/strategies/index.js.map +1 -1
- package/dist/infrastructure/logging/index.d.ts +2 -0
- package/dist/infrastructure/logging/index.d.ts.map +1 -0
- package/dist/infrastructure/logging/index.js +2 -0
- package/dist/infrastructure/logging/index.js.map +1 -0
- package/dist/infrastructure/logging/logger.d.ts +25 -0
- package/dist/infrastructure/logging/logger.d.ts.map +1 -0
- package/dist/infrastructure/logging/logger.js +54 -0
- package/dist/infrastructure/logging/logger.js.map +1 -0
- package/dist/infrastructure/parser/analysis-types.d.ts.map +1 -1
- package/dist/infrastructure/parser/base.d.ts +1 -6
- package/dist/infrastructure/parser/base.d.ts.map +1 -1
- package/dist/infrastructure/parser/base.js +4 -16
- package/dist/infrastructure/parser/base.js.map +1 -1
- package/dist/infrastructure/parser/index.d.ts +2 -2
- package/dist/infrastructure/parser/index.d.ts.map +1 -1
- package/dist/infrastructure/parser/index.js +1 -1
- package/dist/infrastructure/parser/index.js.map +1 -1
- package/dist/infrastructure/parser/interface.d.ts +0 -7
- package/dist/infrastructure/parser/interface.d.ts.map +1 -1
- package/dist/infrastructure/parser/interface.js +0 -1
- package/dist/infrastructure/parser/interface.js.map +1 -1
- package/dist/infrastructure/parser/registry.d.ts.map +1 -1
- package/dist/infrastructure/parser/registry.js +2 -1
- package/dist/infrastructure/parser/registry.js.map +1 -1
- package/dist/infrastructure/parser/types.d.ts +12 -3
- package/dist/infrastructure/parser/types.d.ts.map +1 -1
- package/dist/infrastructure/parser/types.js +7 -2
- package/dist/infrastructure/parser/types.js.map +1 -1
- package/dist/infrastructure/storage/file-system.d.ts.map +1 -1
- package/dist/infrastructure/storage/file-system.js +5 -1
- package/dist/infrastructure/storage/file-system.js.map +1 -1
- package/dist/interfaces/cli/cached-index-engine.d.ts +25 -0
- package/dist/interfaces/cli/cached-index-engine.d.ts.map +1 -0
- package/dist/interfaces/cli/cached-index-engine.js +59 -0
- package/dist/interfaces/cli/cached-index-engine.js.map +1 -0
- package/dist/interfaces/cli/cli.d.ts +1 -0
- package/dist/interfaces/cli/cli.d.ts.map +1 -1
- package/dist/interfaces/cli/cli.js +33 -19
- package/dist/interfaces/cli/cli.js.map +1 -1
- package/dist/interfaces/cli/command-utils.d.ts +17 -1
- package/dist/interfaces/cli/command-utils.d.ts.map +1 -1
- package/dist/interfaces/cli/command-utils.js +53 -3
- package/dist/interfaces/cli/command-utils.js.map +1 -1
- package/dist/interfaces/cli/commands/call-hierarchy.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/call-hierarchy.command.js +57 -17
- package/dist/interfaces/cli/commands/call-hierarchy.command.js.map +1 -1
- package/dist/interfaces/cli/commands/change-signature.command.d.ts +12 -0
- package/dist/interfaces/cli/commands/change-signature.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/change-signature.command.js +131 -12
- package/dist/interfaces/cli/commands/change-signature.command.js.map +1 -1
- package/dist/interfaces/cli/commands/cycles.command.d.ts +1 -1
- package/dist/interfaces/cli/commands/cycles.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/cycles.command.js +13 -11
- package/dist/interfaces/cli/commands/cycles.command.js.map +1 -1
- package/dist/interfaces/cli/commands/deadcode.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/deadcode.command.js +18 -19
- package/dist/interfaces/cli/commands/deadcode.command.js.map +1 -1
- package/dist/interfaces/cli/commands/find-references.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/find-references.command.js +35 -11
- package/dist/interfaces/cli/commands/find-references.command.js.map +1 -1
- package/dist/interfaces/cli/commands/impact.command.d.ts +1 -1
- package/dist/interfaces/cli/commands/impact.command.js +6 -13
- package/dist/interfaces/cli/commands/impact.command.js.map +1 -1
- package/dist/interfaces/cli/commands/index.d.ts +1 -1
- package/dist/interfaces/cli/commands/index.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/index.js +1 -1
- package/dist/interfaces/cli/commands/index.js.map +1 -1
- package/dist/interfaces/cli/commands/move-command-options.d.ts +14 -0
- package/dist/interfaces/cli/commands/move-command-options.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/move-command-options.js +2 -0
- package/dist/interfaces/cli/commands/move-command-options.js.map +1 -0
- package/dist/interfaces/cli/commands/move-glob-command-handler.d.ts +8 -0
- package/dist/interfaces/cli/commands/move-glob-command-handler.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/move-glob-command-handler.js +186 -0
- package/dist/interfaces/cli/commands/move-glob-command-handler.js.map +1 -0
- package/dist/interfaces/cli/commands/move.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/move.command.js +62 -241
- package/dist/interfaces/cli/commands/move.command.js.map +1 -1
- package/dist/interfaces/cli/commands/rename.command.d.ts.map +1 -1
- package/dist/interfaces/cli/commands/rename.command.js +40 -26
- package/dist/interfaces/cli/commands/rename.command.js.map +1 -1
- package/dist/interfaces/cli/commands/search.command.d.ts +11 -0
- package/dist/interfaces/cli/commands/search.command.d.ts.map +1 -0
- package/dist/interfaces/cli/commands/search.command.js +110 -0
- package/dist/interfaces/cli/commands/search.command.js.map +1 -0
- package/dist/interfaces/cli/unified-output-handler.d.ts +5 -0
- package/dist/interfaces/cli/unified-output-handler.d.ts.map +1 -1
- package/dist/interfaces/cli/unified-output-handler.js +8 -1
- package/dist/interfaces/cli/unified-output-handler.js.map +1 -1
- package/dist/plugins/javascript/declaration-analyzer.d.ts.map +1 -1
- package/dist/plugins/javascript/declaration-analyzer.js +5 -2
- package/dist/plugins/javascript/declaration-analyzer.js.map +1 -1
- package/dist/plugins/javascript/parser.d.ts +6 -4
- package/dist/plugins/javascript/parser.d.ts.map +1 -1
- package/dist/plugins/javascript/parser.js +97 -15
- package/dist/plugins/javascript/parser.js.map +1 -1
- package/dist/plugins/javascript/reference-finder.d.ts.map +1 -1
- package/dist/plugins/javascript/reference-finder.js +3 -1
- package/dist/plugins/javascript/reference-finder.js.map +1 -1
- package/dist/plugins/javascript/types.js +10 -10
- package/dist/plugins/javascript/types.js.map +1 -1
- package/dist/plugins/shared/constants.d.ts +1 -1
- package/dist/plugins/shared/constants.d.ts.map +1 -1
- package/dist/plugins/shared/constants.js +7 -1
- package/dist/plugins/shared/constants.js.map +1 -1
- package/dist/plugins/shared/parser-helpers.d.ts.map +1 -1
- package/dist/plugins/shared/parser-helpers.js +1 -0
- package/dist/plugins/shared/parser-helpers.js.map +1 -1
- package/dist/plugins/shared/utils/memory-monitor.d.ts.map +1 -1
- package/dist/plugins/shared/utils/memory-monitor.js +3 -2
- package/dist/plugins/shared/utils/memory-monitor.js.map +1 -1
- package/dist/plugins/shared/utils/object.d.ts.map +1 -1
- package/dist/plugins/shared/utils/object.js +8 -12
- package/dist/plugins/shared/utils/object.js.map +1 -1
- package/dist/plugins/typescript/declaration-analyzer.d.ts.map +1 -1
- package/dist/plugins/typescript/declaration-analyzer.js +9 -4
- package/dist/plugins/typescript/declaration-analyzer.js.map +1 -1
- package/dist/plugins/typescript/language-service.js +1 -1
- package/dist/plugins/typescript/language-service.js.map +1 -1
- package/dist/plugins/typescript/parser.d.ts +1 -6
- package/dist/plugins/typescript/parser.d.ts.map +1 -1
- package/dist/plugins/typescript/parser.js +7 -33
- package/dist/plugins/typescript/parser.js.map +1 -1
- package/dist/plugins/typescript/pattern-analyzer.d.ts.map +1 -1
- package/dist/plugins/typescript/pattern-analyzer.js +3 -1
- package/dist/plugins/typescript/pattern-analyzer.js.map +1 -1
- package/dist/plugins/typescript/reference-finder.d.ts.map +1 -1
- package/dist/plugins/typescript/reference-finder.js +3 -1
- package/dist/plugins/typescript/reference-finder.js.map +1 -1
- package/dist/plugins/typescript/tsconfig-loader.d.ts.map +1 -1
- package/dist/plugins/typescript/tsconfig-loader.js +162 -24
- package/dist/plugins/typescript/tsconfig-loader.js.map +1 -1
- package/dist/plugins/typescript/types.js +3 -3
- package/dist/plugins/typescript/types.js.map +1 -1
- package/dist/shared/errors/diagnostic-collector.d.ts +47 -0
- package/dist/shared/errors/diagnostic-collector.d.ts.map +1 -0
- package/dist/shared/errors/diagnostic-collector.js +89 -0
- package/dist/shared/errors/diagnostic-collector.js.map +1 -0
- package/dist/shared/errors/index.d.ts +3 -0
- package/dist/shared/errors/index.d.ts.map +1 -1
- package/dist/shared/errors/index.js +5 -1
- package/dist/shared/errors/index.js.map +1 -1
- package/dist/shared/types/index.d.ts +1 -0
- package/dist/shared/types/index.d.ts.map +1 -1
- package/dist/shared/types/index.js +2 -0
- package/dist/shared/types/index.js.map +1 -1
- package/dist/shared/types/source-file-extensions.d.ts +14 -0
- package/dist/shared/types/source-file-extensions.d.ts.map +1 -0
- package/dist/shared/types/source-file-extensions.js +42 -0
- package/dist/shared/types/source-file-extensions.js.map +1 -0
- package/dist/shared/types/symbol.d.ts +1 -0
- package/dist/shared/types/symbol.d.ts.map +1 -1
- package/dist/shared/types/symbol.js.map +1 -1
- package/package.json +18 -12
- package/dist/application/events/event-bus.d.ts +0 -107
- package/dist/application/events/event-bus.d.ts.map +0 -1
- package/dist/application/events/event-bus.js +0 -369
- package/dist/application/events/event-bus.js.map +0 -1
- package/dist/application/events/event-types.d.ts +0 -195
- package/dist/application/events/event-types.d.ts.map +0 -1
- package/dist/application/events/event-types.js +0 -36
- package/dist/application/events/event-types.js.map +0 -1
- package/dist/application/events/index.d.ts +0 -6
- package/dist/application/events/index.d.ts.map +0 -1
- package/dist/application/events/index.js +0 -6
- package/dist/application/events/index.js.map +0 -1
- package/dist/application/index.d.ts +0 -76
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/index.js +0 -127
- package/dist/application/index.js.map +0 -1
- package/dist/application/services/cache-coordinator.service.d.ts +0 -69
- package/dist/application/services/cache-coordinator.service.d.ts.map +0 -1
- package/dist/application/services/cache-coordinator.service.js +0 -251
- package/dist/application/services/cache-coordinator.service.js.map +0 -1
- package/dist/application/services/error-handler.service.d.ts +0 -56
- package/dist/application/services/error-handler.service.d.ts.map +0 -1
- package/dist/application/services/error-handler.service.js +0 -273
- package/dist/application/services/error-handler.service.js.map +0 -1
- package/dist/application/services/index.d.ts +0 -8
- package/dist/application/services/index.d.ts.map +0 -1
- package/dist/application/services/index.js +0 -8
- package/dist/application/services/index.js.map +0 -1
- package/dist/application/services/module-coordinator.service.d.ts +0 -55
- package/dist/application/services/module-coordinator.service.d.ts.map +0 -1
- package/dist/application/services/module-coordinator.service.js +0 -185
- package/dist/application/services/module-coordinator.service.js.map +0 -1
- package/dist/application/services/session-manager.service.d.ts +0 -86
- package/dist/application/services/session-manager.service.d.ts.map +0 -1
- package/dist/application/services/session-manager.service.js +0 -321
- package/dist/application/services/session-manager.service.js.map +0 -1
- package/dist/application/state/application-state.d.ts +0 -164
- package/dist/application/state/application-state.d.ts.map +0 -1
- package/dist/application/state/application-state.js +0 -290
- package/dist/application/state/application-state.js.map +0 -1
- package/dist/application/state/index.d.ts +0 -15
- package/dist/application/state/index.d.ts.map +0 -1
- package/dist/application/state/index.js +0 -15
- package/dist/application/state/index.js.map +0 -1
- package/dist/application/state/session-state.d.ts +0 -114
- package/dist/application/state/session-state.d.ts.map +0 -1
- package/dist/application/state/session-state.js +0 -188
- package/dist/application/state/session-state.js.map +0 -1
- package/dist/application/state/state-manager.d.ts +0 -122
- package/dist/application/state/state-manager.d.ts.map +0 -1
- package/dist/application/state/state-manager.js +0 -234
- package/dist/application/state/state-manager.js.map +0 -1
- package/dist/application/types.d.ts +0 -217
- package/dist/application/types.d.ts.map +0 -1
- package/dist/application/types.js +0 -5
- package/dist/application/types.js.map +0 -1
- package/dist/core/find-references/index.d.ts +0 -12
- package/dist/core/find-references/index.d.ts.map +0 -1
- package/dist/core/find-references/index.js +0 -14
- package/dist/core/find-references/index.js.map +0 -1
- package/dist/core/find-references/reference-finder-engine.d.ts +0 -75
- package/dist/core/find-references/reference-finder-engine.d.ts.map +0 -1
- package/dist/core/find-references/reference-finder-engine.js +0 -87
- package/dist/core/find-references/reference-finder-engine.js.map +0 -1
- package/dist/core/find-references/types.d.ts +0 -6
- package/dist/core/find-references/types.d.ts.map +0 -1
- package/dist/core/find-references/types.js +0 -7
- package/dist/core/find-references/types.js.map +0 -1
- package/dist/core/snapshot/index.d.ts +0 -9
- package/dist/core/snapshot/index.d.ts.map +0 -1
- package/dist/core/snapshot/index.js +0 -7
- package/dist/core/snapshot/index.js.map +0 -1
- package/dist/core/snapshot/snapshot-cache.d.ts +0 -103
- package/dist/core/snapshot/snapshot-cache.d.ts.map +0 -1
- package/dist/core/snapshot/snapshot-cache.js +0 -249
- package/dist/core/snapshot/snapshot-cache.js.map +0 -1
- package/dist/core/snapshot/snapshot-generator.d.ts +0 -79
- package/dist/core/snapshot/snapshot-generator.d.ts.map +0 -1
- package/dist/core/snapshot/snapshot-generator.js +0 -381
- package/dist/core/snapshot/snapshot-generator.js.map +0 -1
- package/dist/core/snapshot/types.d.ts +0 -67
- package/dist/core/snapshot/types.d.ts.map +0 -1
- package/dist/core/snapshot/types.js +0 -25
- package/dist/core/snapshot/types.js.map +0 -1
- package/dist/core/snapshot/utils/bracket-balancer.d.ts +0 -27
- package/dist/core/snapshot/utils/bracket-balancer.d.ts.map +0 -1
- package/dist/core/snapshot/utils/bracket-balancer.js +0 -70
- package/dist/core/snapshot/utils/bracket-balancer.js.map +0 -1
- package/dist/core/snapshot/utils/factory-pattern-detector.d.ts +0 -22
- package/dist/core/snapshot/utils/factory-pattern-detector.d.ts.map +0 -1
- package/dist/core/snapshot/utils/factory-pattern-detector.js +0 -70
- package/dist/core/snapshot/utils/factory-pattern-detector.js.map +0 -1
- package/dist/core/snapshot/utils/index.d.ts +0 -7
- package/dist/core/snapshot/utils/index.d.ts.map +0 -1
- package/dist/core/snapshot/utils/index.js +0 -7
- package/dist/core/snapshot/utils/index.js.map +0 -1
- package/dist/core/snapshot/utils/symbol-formatter.d.ts +0 -37
- package/dist/core/snapshot/utils/symbol-formatter.d.ts.map +0 -1
- package/dist/core/snapshot/utils/symbol-formatter.js +0 -89
- package/dist/core/snapshot/utils/symbol-formatter.js.map +0 -1
- package/dist/infrastructure/formatters/diff-utils.d.ts +0 -24
- package/dist/infrastructure/formatters/diff-utils.d.ts.map +0 -1
- package/dist/infrastructure/formatters/diff-utils.js +0 -104
- package/dist/infrastructure/formatters/diff-utils.js.map +0 -1
- package/dist/infrastructure/formatters/preview-converter.d.ts +0 -148
- package/dist/infrastructure/formatters/preview-converter.d.ts.map +0 -1
- package/dist/infrastructure/formatters/preview-converter.js +0 -329
- package/dist/infrastructure/formatters/preview-converter.js.map +0 -1
- package/dist/infrastructure/formatters/strategies/analyze-formatter.d.ts +0 -24
- package/dist/infrastructure/formatters/strategies/analyze-formatter.d.ts.map +0 -1
- package/dist/infrastructure/formatters/strategies/analyze-formatter.js +0 -102
- package/dist/infrastructure/formatters/strategies/analyze-formatter.js.map +0 -1
- package/dist/infrastructure/formatters/strategies/deps-formatter.d.ts +0 -15
- package/dist/infrastructure/formatters/strategies/deps-formatter.d.ts.map +0 -1
- package/dist/infrastructure/formatters/strategies/deps-formatter.js +0 -47
- package/dist/infrastructure/formatters/strategies/deps-formatter.js.map +0 -1
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.d.ts +0 -20
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.d.ts.map +0 -1
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.js +0 -101
- package/dist/infrastructure/formatters/strategies/snapshot-formatter.js.map +0 -1
- package/dist/interfaces/cli/commands/snapshot.command.d.ts +0 -11
- package/dist/interfaces/cli/commands/snapshot.command.d.ts.map +0 -1
- package/dist/interfaces/cli/commands/snapshot.command.js +0 -86
- package/dist/interfaces/cli/commands/snapshot.command.js.map +0 -1
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CacheCoordinator 快取協調服務
|
|
3
|
-
* 統一管理各模組的快取策略,提供全域和模組級別的快取失效、預熱和監控功能
|
|
4
|
-
*/
|
|
5
|
-
import { EventPriority } from '../events/event-types.js';
|
|
6
|
-
import { BaseError } from '../../shared/errors/base-error.js';
|
|
7
|
-
/**
|
|
8
|
-
* 快取協調器錯誤
|
|
9
|
-
*/
|
|
10
|
-
export class CacheCoordinatorError extends BaseError {
|
|
11
|
-
constructor(message, details, cause) {
|
|
12
|
-
super('CACHE_COORDINATOR_ERROR', message, details, cause);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 快取協調服務實作
|
|
17
|
-
*/
|
|
18
|
-
export class CacheCoordinatorService {
|
|
19
|
-
cacheManager;
|
|
20
|
-
eventBus;
|
|
21
|
-
moduleStrategies = new Map();
|
|
22
|
-
disposed = false;
|
|
23
|
-
constructor(cacheManager, eventBus) {
|
|
24
|
-
if (!cacheManager) {
|
|
25
|
-
throw new CacheCoordinatorError('CacheManager 不能為空');
|
|
26
|
-
}
|
|
27
|
-
if (!eventBus) {
|
|
28
|
-
throw new CacheCoordinatorError('EventBus 不能為空');
|
|
29
|
-
}
|
|
30
|
-
this.cacheManager = cacheManager;
|
|
31
|
-
this.eventBus = eventBus;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 配置模組快取策略
|
|
35
|
-
*/
|
|
36
|
-
async configureCache(moduleId, strategy) {
|
|
37
|
-
this.validateNotDisposed();
|
|
38
|
-
this.validateModuleId(moduleId);
|
|
39
|
-
this.validateStrategy(strategy);
|
|
40
|
-
try {
|
|
41
|
-
// 儲存策略配置
|
|
42
|
-
this.moduleStrategies.set(moduleId, strategy);
|
|
43
|
-
// 建立快取實例
|
|
44
|
-
const cacheOptions = this.convertStrategyToCacheOptions(strategy);
|
|
45
|
-
// 如果快取已存在,先刪除
|
|
46
|
-
if (this.cacheManager.hasCache(moduleId)) {
|
|
47
|
-
this.cacheManager.deleteCache(moduleId);
|
|
48
|
-
}
|
|
49
|
-
this.cacheManager.createCache(moduleId, cacheOptions);
|
|
50
|
-
// 發布配置事件
|
|
51
|
-
await this.publishCacheEvent('configuration', {
|
|
52
|
-
moduleId,
|
|
53
|
-
strategy
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
throw new CacheCoordinatorError(`配置模組 ${moduleId} 的快取失敗`, { moduleId, strategy }, error);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* 全域快取失效
|
|
62
|
-
*/
|
|
63
|
-
async invalidateAll() {
|
|
64
|
-
this.validateNotDisposed();
|
|
65
|
-
try {
|
|
66
|
-
this.cacheManager.clearAll();
|
|
67
|
-
// 發布全域失效事件
|
|
68
|
-
await this.publishCacheEvent('invalidation', {});
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
throw new CacheCoordinatorError('全域快取失效失敗', {}, error);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* 模組快取失效
|
|
76
|
-
*/
|
|
77
|
-
async invalidateModule(moduleId) {
|
|
78
|
-
this.validateNotDisposed();
|
|
79
|
-
this.validateModuleId(moduleId);
|
|
80
|
-
if (!this.cacheManager.hasCache(moduleId)) {
|
|
81
|
-
throw new CacheCoordinatorError(`模組 ${moduleId} 的快取不存在`, { moduleId });
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
this.cacheManager.clearCache(moduleId);
|
|
85
|
-
// 發布模組失效事件
|
|
86
|
-
await this.publishCacheEvent('invalidation', { moduleId });
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
throw new CacheCoordinatorError(`模組 ${moduleId} 快取失效失敗`, { moduleId }, error);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* 取得快取統計資訊
|
|
94
|
-
*/
|
|
95
|
-
async getStats() {
|
|
96
|
-
this.validateNotDisposed();
|
|
97
|
-
try {
|
|
98
|
-
const globalStats = this.cacheManager.getGlobalStats();
|
|
99
|
-
const moduleStats = new Map();
|
|
100
|
-
// 收集各模組統計
|
|
101
|
-
for (const moduleId of this.moduleStrategies.keys()) {
|
|
102
|
-
const cache = this.cacheManager.getCache(moduleId);
|
|
103
|
-
if (cache) {
|
|
104
|
-
const cacheStats = cache.getStats();
|
|
105
|
-
const moduleStatsItem = {
|
|
106
|
-
moduleId,
|
|
107
|
-
requests: cacheStats.totalRequests,
|
|
108
|
-
hits: cacheStats.hits,
|
|
109
|
-
misses: cacheStats.misses,
|
|
110
|
-
hitRate: cacheStats.hitRate,
|
|
111
|
-
size: cacheStats.size
|
|
112
|
-
};
|
|
113
|
-
moduleStats.set(moduleId, moduleStatsItem);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const stats = {
|
|
117
|
-
totalRequests: globalStats.totalRequests,
|
|
118
|
-
hits: globalStats.totalHits,
|
|
119
|
-
misses: globalStats.totalMisses,
|
|
120
|
-
hitRate: globalStats.globalHitRate,
|
|
121
|
-
size: globalStats.totalItems,
|
|
122
|
-
maxSize: 0, // 需要根據策略計算
|
|
123
|
-
evictions: globalStats.totalEvictions,
|
|
124
|
-
lastReset: new Date(),
|
|
125
|
-
moduleStats
|
|
126
|
-
};
|
|
127
|
-
return stats;
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
throw new CacheCoordinatorError('取得快取統計失敗', {}, error);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* 快取預熱
|
|
135
|
-
*/
|
|
136
|
-
async warmup(modules) {
|
|
137
|
-
this.validateNotDisposed();
|
|
138
|
-
if (!modules || modules.length === 0) {
|
|
139
|
-
throw new CacheCoordinatorError('模組列表不能為空');
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
for (const moduleId of modules) {
|
|
143
|
-
if (this.cacheManager.hasCache(moduleId)) {
|
|
144
|
-
// 這裡只是呼叫 warmupCache,實際的預熱邏輯在 CacheManager 中
|
|
145
|
-
await this.cacheManager.warmupCache(moduleId);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
console.warn(`模組 ${moduleId} 的快取不存在,跳過預熱`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// 發布預熱事件
|
|
152
|
-
await this.publishCacheEvent('warmup', { modules });
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
// 預熱失敗不拋出錯誤,只記錄日誌
|
|
156
|
-
console.error('快取預熱失敗:', error);
|
|
157
|
-
// 但仍然發布預熱事件
|
|
158
|
-
await this.publishCacheEvent('warmup', { modules, error: error.message });
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* 銷毀服務
|
|
163
|
-
*/
|
|
164
|
-
dispose() {
|
|
165
|
-
if (this.disposed) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
this.moduleStrategies.clear();
|
|
169
|
-
this.disposed = true;
|
|
170
|
-
}
|
|
171
|
-
// ===== 私有方法 =====
|
|
172
|
-
/**
|
|
173
|
-
* 轉換策略為快取選項
|
|
174
|
-
*/
|
|
175
|
-
convertStrategyToCacheOptions(strategy) {
|
|
176
|
-
const options = {};
|
|
177
|
-
switch (strategy.type) {
|
|
178
|
-
case 'lru':
|
|
179
|
-
options.strategy = 'lru';
|
|
180
|
-
if (strategy.maxSize) {
|
|
181
|
-
options.maxSize = strategy.maxSize;
|
|
182
|
-
}
|
|
183
|
-
break;
|
|
184
|
-
case 'lfu':
|
|
185
|
-
options.strategy = 'lfu';
|
|
186
|
-
if (strategy.maxSize) {
|
|
187
|
-
options.maxSize = strategy.maxSize;
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
case 'ttl':
|
|
191
|
-
options.strategy = 'ttl';
|
|
192
|
-
if (strategy.maxAge) {
|
|
193
|
-
options.maxAge = strategy.maxAge;
|
|
194
|
-
}
|
|
195
|
-
break;
|
|
196
|
-
case 'custom':
|
|
197
|
-
if (strategy.customStrategy) {
|
|
198
|
-
options.customStrategy = strategy.customStrategy;
|
|
199
|
-
}
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
return options;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* 發布快取事件
|
|
206
|
-
*/
|
|
207
|
-
async publishCacheEvent(eventType, data) {
|
|
208
|
-
const event = {
|
|
209
|
-
type: 'cache-event',
|
|
210
|
-
timestamp: new Date(),
|
|
211
|
-
priority: EventPriority.NORMAL,
|
|
212
|
-
payload: {
|
|
213
|
-
eventType,
|
|
214
|
-
...data
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
await this.eventBus.emit(event);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* 驗證未被銷毀
|
|
221
|
-
*/
|
|
222
|
-
validateNotDisposed() {
|
|
223
|
-
if (this.disposed) {
|
|
224
|
-
throw new CacheCoordinatorError('CacheCoordinator 已被銷毀');
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* 驗證模組 ID
|
|
229
|
-
*/
|
|
230
|
-
validateModuleId(moduleId) {
|
|
231
|
-
if (!moduleId || typeof moduleId !== 'string' || moduleId.trim() === '') {
|
|
232
|
-
throw new CacheCoordinatorError('模組 ID 不能為空');
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* 驗證策略
|
|
237
|
-
*/
|
|
238
|
-
validateStrategy(strategy) {
|
|
239
|
-
if (!strategy) {
|
|
240
|
-
throw new CacheCoordinatorError('快取策略不能為空');
|
|
241
|
-
}
|
|
242
|
-
const validTypes = ['lru', 'lfu', 'ttl', 'custom'];
|
|
243
|
-
if (!validTypes.includes(strategy.type)) {
|
|
244
|
-
throw new CacheCoordinatorError(`無效的快取策略類型: ${strategy.type}`, { strategy });
|
|
245
|
-
}
|
|
246
|
-
if (strategy.type === 'custom' && !strategy.customStrategy) {
|
|
247
|
-
throw new CacheCoordinatorError('自訂策略必須提供 customStrategy 函式', { strategy });
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
//# sourceMappingURL=cache-coordinator.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache-coordinator.service.js","sourceRoot":"","sources":["../../../src/application/services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;CACF"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ErrorHandler 服務實作
|
|
3
|
-
* 提供統一的錯誤處理、重試機制和錯誤恢復功能
|
|
4
|
-
*/
|
|
5
|
-
import { EventBus } from '../events/event-bus.js';
|
|
6
|
-
import type { IErrorHandler, ErrorContext, HandledError, RetryOptions, RecoveryResult, ErrorStats } from '../types.js';
|
|
7
|
-
/**
|
|
8
|
-
* 錯誤處理服務
|
|
9
|
-
*/
|
|
10
|
-
export declare class ErrorHandlerService implements IErrorHandler {
|
|
11
|
-
private readonly eventBus;
|
|
12
|
-
private readonly errorStats;
|
|
13
|
-
private readonly maxRecentErrors;
|
|
14
|
-
constructor(eventBus: EventBus);
|
|
15
|
-
/**
|
|
16
|
-
* 處理錯誤並返回 HandledError
|
|
17
|
-
*/
|
|
18
|
-
handle(error: Error, context: ErrorContext): Promise<HandledError>;
|
|
19
|
-
/**
|
|
20
|
-
* 重試操作
|
|
21
|
-
*/
|
|
22
|
-
retry<T>(operation: () => Promise<T>, options: RetryOptions): Promise<T>;
|
|
23
|
-
/**
|
|
24
|
-
* 恢復錯誤
|
|
25
|
-
*/
|
|
26
|
-
recover(error: HandledError): Promise<RecoveryResult>;
|
|
27
|
-
/**
|
|
28
|
-
* 取得錯誤統計
|
|
29
|
-
*/
|
|
30
|
-
getErrorStats(): Promise<ErrorStats>;
|
|
31
|
-
/**
|
|
32
|
-
* 建立 HandledError
|
|
33
|
-
*/
|
|
34
|
-
private createHandledError;
|
|
35
|
-
/**
|
|
36
|
-
* 更新錯誤統計
|
|
37
|
-
*/
|
|
38
|
-
private updateErrorStats;
|
|
39
|
-
/**
|
|
40
|
-
* 發布錯誤事件
|
|
41
|
-
*/
|
|
42
|
-
private publishErrorEvent;
|
|
43
|
-
/**
|
|
44
|
-
* 生成用戶友好的錯誤訊息
|
|
45
|
-
*/
|
|
46
|
-
private generateUserFriendlyMessage;
|
|
47
|
-
/**
|
|
48
|
-
* 計算延遲時間
|
|
49
|
-
*/
|
|
50
|
-
private calculateDelay;
|
|
51
|
-
/**
|
|
52
|
-
* 休眠指定時間
|
|
53
|
-
*/
|
|
54
|
-
private sleep;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=error-handler.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.service.d.ts","sourceRoot":"","sources":["../../../src/application/services/error-handler.service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,UAAU,EAEX,MAAM,aAAa,CAAC;AA2BrB;;GAEG;AACH,qBAAa,mBAAoB,YAAW,aAAa;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAOzB;IAEF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAM;gBAE1B,QAAQ,EAAE,QAAQ;IAY9B;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAaxE;;OAEG;IACG,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC;IAwC9E;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;IA+D3D;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAW1C;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA0B1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAmBxB;;OAEG;YACW,iBAAiB;IAqB/B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAsCnC;;OAEG;IACH,OAAO,CAAC,cAAc;IAiBtB;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ErrorHandler 服務實作
|
|
3
|
-
* 提供統一的錯誤處理、重試機制和錯誤恢復功能
|
|
4
|
-
*/
|
|
5
|
-
import { BaseError } from '../../shared/errors/base-error.js';
|
|
6
|
-
import { EventPriority } from '../events/event-types.js';
|
|
7
|
-
/**
|
|
8
|
-
* 已處理錯誤實作
|
|
9
|
-
*/
|
|
10
|
-
class HandledErrorImpl extends BaseError {
|
|
11
|
-
handled = true;
|
|
12
|
-
context;
|
|
13
|
-
recovery;
|
|
14
|
-
userMessage;
|
|
15
|
-
constructor(code, message, context, details, cause, userMessage, recovery) {
|
|
16
|
-
super(code, message, details, cause);
|
|
17
|
-
this.context = context;
|
|
18
|
-
this.userMessage = userMessage;
|
|
19
|
-
this.recovery = recovery;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 錯誤處理服務
|
|
24
|
-
*/
|
|
25
|
-
export class ErrorHandlerService {
|
|
26
|
-
eventBus;
|
|
27
|
-
errorStats;
|
|
28
|
-
maxRecentErrors = 10;
|
|
29
|
-
constructor(eventBus) {
|
|
30
|
-
this.eventBus = eventBus;
|
|
31
|
-
this.errorStats = {
|
|
32
|
-
totalErrors: 0,
|
|
33
|
-
handledErrors: 0,
|
|
34
|
-
recoveredErrors: 0,
|
|
35
|
-
errorsByModule: new Map(),
|
|
36
|
-
errorsByType: new Map(),
|
|
37
|
-
recentErrors: []
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* 處理錯誤並返回 HandledError
|
|
42
|
-
*/
|
|
43
|
-
async handle(error, context) {
|
|
44
|
-
// 更新統計
|
|
45
|
-
this.updateErrorStats(error, context);
|
|
46
|
-
// 建立 HandledError
|
|
47
|
-
const handledError = this.createHandledError(error, context);
|
|
48
|
-
// 發布錯誤事件
|
|
49
|
-
await this.publishErrorEvent(handledError, context);
|
|
50
|
-
return handledError;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* 重試操作
|
|
54
|
-
*/
|
|
55
|
-
async retry(operation, options) {
|
|
56
|
-
const { maxAttempts, backoff = 'linear', initialDelay = 1000, maxDelay = 30000, shouldRetry } = options;
|
|
57
|
-
let lastError = new Error('No attempts made');
|
|
58
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
59
|
-
try {
|
|
60
|
-
return await operation();
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
lastError = error;
|
|
64
|
-
// 檢查是否應該重試
|
|
65
|
-
if (shouldRetry && !shouldRetry(lastError, attempt)) {
|
|
66
|
-
throw lastError;
|
|
67
|
-
}
|
|
68
|
-
// 如果是最後一次嘗試,直接拋出錯誤
|
|
69
|
-
if (attempt === maxAttempts) {
|
|
70
|
-
throw lastError;
|
|
71
|
-
}
|
|
72
|
-
// 計算延遲時間
|
|
73
|
-
const delay = this.calculateDelay(backoff, attempt, initialDelay, maxDelay);
|
|
74
|
-
// 等待延遲
|
|
75
|
-
if (delay > 0) {
|
|
76
|
-
await this.sleep(delay);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
throw lastError;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 恢復錯誤
|
|
84
|
-
*/
|
|
85
|
-
async recover(error) {
|
|
86
|
-
if (!error.recovery) {
|
|
87
|
-
return {
|
|
88
|
-
success: false,
|
|
89
|
-
recoveryType: 'none'
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
const { recovery } = error;
|
|
93
|
-
try {
|
|
94
|
-
switch (recovery.type) {
|
|
95
|
-
case 'retry':
|
|
96
|
-
if (recovery.action && recovery.retryOptions) {
|
|
97
|
-
const result = await this.retry(recovery.action, recovery.retryOptions);
|
|
98
|
-
this.errorStats.recoveredErrors++;
|
|
99
|
-
return {
|
|
100
|
-
success: true,
|
|
101
|
-
recoveryType: 'retry',
|
|
102
|
-
result
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
case 'fallback':
|
|
107
|
-
this.errorStats.recoveredErrors++;
|
|
108
|
-
return {
|
|
109
|
-
success: true,
|
|
110
|
-
recoveryType: 'fallback',
|
|
111
|
-
result: recovery.fallbackValue
|
|
112
|
-
};
|
|
113
|
-
case 'ignore':
|
|
114
|
-
this.errorStats.recoveredErrors++;
|
|
115
|
-
return {
|
|
116
|
-
success: true,
|
|
117
|
-
recoveryType: 'ignore'
|
|
118
|
-
};
|
|
119
|
-
case 'manual':
|
|
120
|
-
return {
|
|
121
|
-
success: false,
|
|
122
|
-
recoveryType: 'manual'
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
success: false,
|
|
127
|
-
recoveryType: recovery.type
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
catch (recoveryError) {
|
|
131
|
-
return {
|
|
132
|
-
success: false,
|
|
133
|
-
recoveryType: recovery.type,
|
|
134
|
-
error: recoveryError instanceof BaseError ? recoveryError : new BaseError('RECOVERY_ERROR', '錯誤恢復失敗', { originalError: error.message, recoveryError: recoveryError.message })
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* 取得錯誤統計
|
|
140
|
-
*/
|
|
141
|
-
async getErrorStats() {
|
|
142
|
-
return {
|
|
143
|
-
totalErrors: this.errorStats.totalErrors,
|
|
144
|
-
handledErrors: this.errorStats.handledErrors,
|
|
145
|
-
recoveredErrors: this.errorStats.recoveredErrors,
|
|
146
|
-
errorsByModule: new Map(this.errorStats.errorsByModule),
|
|
147
|
-
errorsByType: new Map(this.errorStats.errorsByType),
|
|
148
|
-
recentErrors: [...this.errorStats.recentErrors]
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* 建立 HandledError
|
|
153
|
-
*/
|
|
154
|
-
createHandledError(error, context) {
|
|
155
|
-
let code;
|
|
156
|
-
let details;
|
|
157
|
-
let cause;
|
|
158
|
-
// 如果是 BaseError,保持其屬性
|
|
159
|
-
if (error instanceof BaseError) {
|
|
160
|
-
code = error.code;
|
|
161
|
-
details = error.details;
|
|
162
|
-
cause = error.cause;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
code = 'GENERIC_ERROR';
|
|
166
|
-
details = { originalName: error.name };
|
|
167
|
-
cause = error;
|
|
168
|
-
}
|
|
169
|
-
return new HandledErrorImpl(code, error.message, context, details, cause, this.generateUserFriendlyMessage(error));
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* 更新錯誤統計
|
|
173
|
-
*/
|
|
174
|
-
updateErrorStats(error, context) {
|
|
175
|
-
this.errorStats.totalErrors++;
|
|
176
|
-
this.errorStats.handledErrors++;
|
|
177
|
-
// 按模組統計
|
|
178
|
-
const moduleCount = this.errorStats.errorsByModule.get(context.module) || 0;
|
|
179
|
-
this.errorStats.errorsByModule.set(context.module, moduleCount + 1);
|
|
180
|
-
// 按錯誤類型統計
|
|
181
|
-
const typeCount = this.errorStats.errorsByType.get(error.constructor.name) || 0;
|
|
182
|
-
this.errorStats.errorsByType.set(error.constructor.name, typeCount + 1);
|
|
183
|
-
// 添加到最近錯誤(限制數量)
|
|
184
|
-
this.errorStats.recentErrors.unshift(context);
|
|
185
|
-
if (this.errorStats.recentErrors.length > this.maxRecentErrors) {
|
|
186
|
-
this.errorStats.recentErrors = this.errorStats.recentErrors.slice(0, this.maxRecentErrors);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* 發布錯誤事件
|
|
191
|
-
*/
|
|
192
|
-
async publishErrorEvent(error, context) {
|
|
193
|
-
try {
|
|
194
|
-
await this.eventBus.emit({
|
|
195
|
-
type: 'error-event',
|
|
196
|
-
timestamp: new Date(),
|
|
197
|
-
priority: EventPriority.NORMAL,
|
|
198
|
-
payload: {
|
|
199
|
-
error,
|
|
200
|
-
context,
|
|
201
|
-
handled: true
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
catch (eventError) {
|
|
206
|
-
// 避免在錯誤處理中產生無限迴圈
|
|
207
|
-
// 在生產環境中應該記錄這個錯誤,但在測試中靜默處理
|
|
208
|
-
if (process.env.NODE_ENV !== 'test') {
|
|
209
|
-
console.error('Failed to publish error event:', eventError);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* 生成用戶友好的錯誤訊息
|
|
215
|
-
*/
|
|
216
|
-
generateUserFriendlyMessage(error) {
|
|
217
|
-
if (error instanceof BaseError) {
|
|
218
|
-
switch (error.code) {
|
|
219
|
-
case 'VALIDATION_ERROR':
|
|
220
|
-
return '資料驗證失敗,請檢查輸入內容是否正確。';
|
|
221
|
-
case 'NETWORK_ERROR':
|
|
222
|
-
return '網路連線發生問題,請檢查網路狀態後重試。';
|
|
223
|
-
case 'FILE_NOT_FOUND':
|
|
224
|
-
return '找不到指定的檔案,請確認檔案路徑是否正確。';
|
|
225
|
-
case 'PERMISSION_ERROR':
|
|
226
|
-
return '權限不足,無法執行此操作。';
|
|
227
|
-
case 'TIMEOUT_ERROR':
|
|
228
|
-
return '操作逾時,請稍後重試。';
|
|
229
|
-
case 'DEPENDENCY_ERROR':
|
|
230
|
-
return '相依性錯誤,請檢查相關模組狀態。';
|
|
231
|
-
case 'PARSE_ERROR':
|
|
232
|
-
return '解析錯誤,檔案格式可能不正確。';
|
|
233
|
-
case 'INDEX_ERROR':
|
|
234
|
-
return '索引操作失敗,請重新建立索引。';
|
|
235
|
-
case 'CACHE_ERROR':
|
|
236
|
-
return '快取操作失敗,系統將嘗試重新載入資料。';
|
|
237
|
-
default:
|
|
238
|
-
return `系統發生錯誤:${error.message}`;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
// 處理一般錯誤
|
|
242
|
-
if (error.name === 'TypeError') {
|
|
243
|
-
return '資料類型錯誤,請確認輸入格式是否正確。';
|
|
244
|
-
}
|
|
245
|
-
else if (error.name === 'RangeError') {
|
|
246
|
-
return '數值超出有效範圍,請調整輸入值。';
|
|
247
|
-
}
|
|
248
|
-
else if (error.name === 'SyntaxError') {
|
|
249
|
-
return '語法錯誤,請檢查程式碼格式。';
|
|
250
|
-
}
|
|
251
|
-
return `系統發生錯誤,請聯繫技術支援。錯誤訊息:${error.message}`;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* 計算延遲時間
|
|
255
|
-
*/
|
|
256
|
-
calculateDelay(backoff, attempt, initialDelay, maxDelay) {
|
|
257
|
-
let delay;
|
|
258
|
-
if (backoff === 'exponential') {
|
|
259
|
-
delay = initialDelay * Math.pow(2, attempt - 1);
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
delay = initialDelay * attempt;
|
|
263
|
-
}
|
|
264
|
-
return Math.min(delay, maxDelay);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* 休眠指定時間
|
|
268
|
-
*/
|
|
269
|
-
sleep(ms) {
|
|
270
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
//# sourceMappingURL=error-handler.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.service.js","sourceRoot":"","sources":["../../../src/application/services/error-handler.service.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAWnE;;GAEG;AACH,MAAM,gBAAiB,SAAQ,SAAS;IACtB,OAAO,GAAY,IAAI,CAAC;IACxB,OAAO,CAAe;IACtB,QAAQ,CAAoB;IAC5B,WAAW,CAAU;IAErC,YACE,IAAY,EACZ,OAAe,EACf,OAAqB,EACrB,OAAiC,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ACN,KAAK,GAAG,YAAY,GAAG,OAAO,CAAC;QACjC,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Application Services 匯出模組
|
|
3
|
-
*/
|
|
4
|
-
export { CacheCoordinatorService, CacheCoordinatorError } from './cache-coordinator.service.js';
|
|
5
|
-
export { ErrorHandlerService } from './error-handler.service.js';
|
|
6
|
-
export { SessionManager, SessionManagerError, SessionNotFoundError } from './session-manager.service.js';
|
|
7
|
-
export { ModuleCoordinatorService, ModuleCoordinatorError } from './module-coordinator.service.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/application/services/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Application Services 匯出模組
|
|
3
|
-
*/
|
|
4
|
-
export { CacheCoordinatorService, CacheCoordinatorError } from './cache-coordinator.service.js';
|
|
5
|
-
export { ErrorHandlerService } from './error-handler.service.js';
|
|
6
|
-
export { SessionManager, SessionManagerError, SessionNotFoundError } from './session-manager.service.js';
|
|
7
|
-
export { ModuleCoordinatorService, ModuleCoordinatorError } from './module-coordinator.service.js';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/application/services/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,iCAAiC,CAAC"}
|