Skip to content

Conversation

@fraxken
Copy link
Member

@fraxken fraxken commented Dec 14, 2025

No description provided.

@fraxken fraxken marked this pull request as ready for review December 15, 2025 16:34
Update workspaces/cache/docs/AppCache.md

Co-authored-by: PierreDemailly <[email protected]>

Update workspaces/cache/docs/AppCache.md

Co-authored-by: PierreDemailly <[email protected]>

Update workspaces/cache/docs/AppCache.md

Co-authored-by: PierreDemailly <[email protected]>

Update workspaces/cache/docs/AppCache.md

Co-authored-by: PierreDemailly <[email protected]>
@fraxken fraxken merged commit 96af191 into master Dec 15, 2025
13 checks passed
@fraxken fraxken deleted the refactor-app-cache branch December 15, 2025 17:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the cache system to separate web UI settings from payload caching by introducing a generic FilePersistanceProvider class. The previous monolithic AppCache class handled both configuration and payload caching, which has now been split into specialized components.

Key changes:

  • Introduced FilePersistanceProvider<T> as a generic file-based caching abstraction using cacache
  • Moved payload-related caching logic to a dedicated AppCache.ts file
  • Implemented web UI settings caching using FilePersistanceProvider in the server's config module

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
workspaces/cache/src/FilePersistanceProvider.ts New generic file persistence provider with get/set/remove methods for cached data
workspaces/cache/src/AppCache.ts Extracted AppCache class from index.ts, focusing on payload management
workspaces/cache/src/index.ts Refactored to export both AppCache and FilePersistanceProvider via barrel exports
workspaces/server/src/config.ts Refactored to use FilePersistanceProvider for web UI settings instead of AppCache
workspaces/server/src/cache.ts Removed AppConfig export, simplified to only export cache instance
workspaces/server/src/endpoints/config.ts Updated to use WebUISettings type instead of AppConfig
workspaces/server/src/index.ts Added config module export for external access
workspaces/server/src/websocket/*.ts Updated imports to reference AppCache from dist directory
workspaces/cache/test/FilePersistanceProvider.test.ts New comprehensive test suite for FilePersistanceProvider
workspaces/server/test/config.test.ts Updated to use FilePersistanceProvider instead of cacache directly
workspaces/server/test/httpServer.test.ts Updated to use config module methods instead of direct cacache access
workspaces/cache/test/index.test.ts Removed config-related test now covered in server tests
workspaces/cache/package.json Updated test script to run all test files
workspaces/cache/docs/*.md Added documentation for AppCache and FilePersistanceProvider
workspaces/cache/README.md Updated to reference new documentation structure
src/commands/cache.js Added config.setDefault() call when clearing cache

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import { match } from "ts-pattern";
import type { Logger } from "pino";
import type { AppCache } from "@nodesecure/cache";
import type { AppCache } from "@nodesecure/cache/dist/AppCache.ts";
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path references the compiled output directory (/dist/AppCache.ts) instead of using the package's main export. Consider importing from "@nodesecure/cache" directly, which would use the barrel export defined in the package's index.ts. This would make the imports more maintainable and follow standard package consumption patterns.

Suggested change
import type { AppCache } from "@nodesecure/cache/dist/AppCache.ts";
import type { AppCache } from "@nodesecure/cache";

Copilot uses AI. Check for mistakes.
// Import Third-party Dependencies
import * as scanner from "@nodesecure/scanner";
import type { PayloadsList, AppCache } from "@nodesecure/cache";
import type { PayloadsList, AppCache } from "@nodesecure/cache/dist/AppCache.ts";
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path references the compiled output directory (/dist/AppCache.ts) instead of using the package's main export. Consider importing from "@nodesecure/cache" directly, which would use the barrel export defined in the package's index.ts. This would make the imports more maintainable and follow standard package consumption patterns.

Suggested change
import type { PayloadsList, AppCache } from "@nodesecure/cache/dist/AppCache.ts";
import type { PayloadsList, AppCache } from "@nodesecure/cache";

Copilot uses AI. Check for mistakes.
@@ -1,5 +1,5 @@
// Import Third-party Dependencies
import type { PayloadsList } from "@nodesecure/cache";
import type { PayloadsList } from "@nodesecure/cache/dist/AppCache.ts";
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path references the compiled output directory (/dist/AppCache.ts) instead of using the package's main export. Consider importing from "@nodesecure/cache" directly, which would use the barrel export defined in the package's index.ts. This would make the imports more maintainable and follow standard package consumption patterns.

Suggested change
import type { PayloadsList } from "@nodesecure/cache/dist/AppCache.ts";
import type { PayloadsList } from "@nodesecure/cache";

Copilot uses AI. Check for mistakes.
}
}
export * from "./AppCache.ts";
export * from "./FilePersistanceProvider.ts";
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "Persistance" should be "Persistence". The filename should be "FilePersistenceProvider.ts" and the export should reference the corrected filename.

Suggested change
export * from "./FilePersistanceProvider.ts";
export * from "./FilePersistenceProvider.ts";

Copilot uses AI. Check for mistakes.
// Import Internal Dependencies
import { FilePersistanceProvider } from "../src/FilePersistanceProvider.ts";

describe("FilePersistanceProvider", () => {
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "Persistance" should be "Persistence". Update test suite name to use the corrected class name.

Copilot uses AI. Check for mistakes.
import { warnings, type WarningName } from "@nodesecure/js-x-ray";
import type { Flag } from "@nodesecure/flags";
import {
FilePersistanceProvider
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "Persistance" should be "Persistence". Update the import to use the corrected class name.

Copilot uses AI. Check for mistakes.
// Import Third-party Dependencies
import type { WebSocket } from "ws";
import type { AppCache, PayloadsList } from "@nodesecure/cache";
import type { AppCache, PayloadsList } from "@nodesecure/cache/dist/AppCache.ts";
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import path references the compiled output directory (/dist/AppCache.ts) instead of using the package's main export. Consider importing from "@nodesecure/cache" directly, which would use the barrel export defined in the package's index.ts. This would make the imports more maintainable and follow standard package consumption patterns.

Suggested change
import type { AppCache, PayloadsList } from "@nodesecure/cache/dist/AppCache.ts";
import type { AppCache, PayloadsList } from "@nodesecure/cache";

Copilot uses AI. Check for mistakes.
## Interfaces

```ts
interface BasePersistanceProvider<T> {
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "Persistance" should be "Persistence". Update the interface name in the documentation.

Suggested change
interface BasePersistanceProvider<T> {
interface BasePersistenceProvider<T> {

Copilot uses AI. Check for mistakes.
}
```
- [AppCache](./docs/AppCache.md)
- [FilePersistanceProvider](./docs/FilePersistanceProvider.md)
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "Persistance" should be "Persistence". Update the documentation link to use the corrected filename.

Suggested change
- [FilePersistanceProvider](./docs/FilePersistanceProvider.md)
- [FilePersistenceProvider](./docs/FilePersistenceProvider.md)

Copilot uses AI. Check for mistakes.
}
catch (err: any) {
logger.error(`[config|get](error: ${err.message})`);
export function getProvider(): FilePersistanceProvider<WebUISettings> {
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error: "Persistance" should be "Persistence". Update the return type to use the corrected class name.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants