Skip to content

HawkStorage abstraction added#164

Open
Reversean wants to merge 1 commit intochore/core-workspacefrom
refactor/hawk-storage
Open

HawkStorage abstraction added#164
Reversean wants to merge 1 commit intochore/core-workspacefrom
refactor/hawk-storage

Conversation

@Reversean
Copy link
Member

@Reversean Reversean commented Feb 16, 2026

Related #151

Added HawkStorage interface which could be used as env-agnositc abstraction to store key-values.

Also HawkLocalStorage implementation based on browser localStorage added.

@Reversean Reversean force-pushed the refactor/hawk-storage branch 3 times, most recently from c3013b6 to 223001d Compare February 17, 2026 13:27
@Reversean Reversean changed the base branch from chore/browser-workspace to chore/core-workspace February 17, 2026 13:49
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

Adds an environment-agnostic storage abstraction to @hawk.so/core and introduces a browser localStorage-backed implementation in @hawk.so/javascript, aligning with the repo’s ongoing split between shared core logic and runtime-specific implementations (Issue #151).

Changes:

  • Added HawkStorage interface to @hawk.so/core and exported it from the core entrypoint.
  • Added HawkLocalStorage implementation and corresponding unit tests in @hawk.so/javascript.
  • Added Vitest coverage support/config updates for the JavaScript package.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
yarn.lock Adds dependencies for Vitest v8 coverage reporting.
packages/javascript/tsconfig.test.json Adds Vitest globals types to the test TS config.
packages/javascript/tests/storages/hawk-local-storage.test.ts Introduces unit tests for the new HawkLocalStorage.
packages/javascript/src/storages/hawk-local-storage.ts Adds a localStorage-backed HawkStorage implementation.
packages/javascript/package.json Adds test:coverage script and coverage dependency.
packages/core/src/storages/hawk-storage.ts Adds the storage interface contract in core.
packages/core/src/index.ts Exports HawkStorage from the core public entrypoint.

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

Comment on lines 43 to 49
"error-stack-parser": "^2.1.4"
},
"devDependencies": {
"@hawk.so/types": "0.5.8",
"@vitest/coverage-v8": "^4.0.18",
"jsdom": "^28.0.0",
"vite": "^7.3.1",
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

HawkLocalStorage imports @hawk.so/core, but @hawk.so/javascript does not declare @hawk.so/core as a dependency/devDependency. With Yarn PnP/workspaces this will fail module resolution and break tests/build. Add @hawk.so/core to this package’s dependencies (typically "workspace:*").

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Added @hawk.so/core as dependency

Comment on lines 8 to 26
* @param key - Storage key to look up.
*/
getItem(key: string): string | null

/**
* Persists a value under the given key.
*
* @param key - Storage key.
* @param value - Value to store.
*/
setItem(key: string, value: string): void

/**
* Removes the entry for the given key.
*
* @param key - Storage key to remove.
*/
removeItem(key: string): void
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

This interface’s method signatures are missing the delimiter semicolons used elsewhere in the repo’s TypeScript interfaces. This is likely to violate the project ESLint/TS style rules (e.g., member-delimiter-style / semi) and should be updated to match existing interfaces.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 1 to 7
import { beforeEach, afterEach, describe, it, expect, vi, Mock } from "vitest";
import { HawkLocalStorage } from "../../src/storages/hawk-local-storage";

describe('HawkLocalStorage', () => {
let getItemSpy: Mock<(key: string) => string | null>;
let setItemSpy: Mock<(key: string, value: string) => void>;
let removeItemSpy: Mock<(key: string) => void>;
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

Mock is only used as a type here, but it’s imported as a runtime named import from vitest. Prefer importing it as a type-only import (or use ReturnType<typeof vi.spyOn> / MockInstance) to avoid requiring a runtime Mock export and to keep the emitted JS clean.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, now importing Mock as type.

Not sure if usage of ReturnType is better sollution since it resolved as any type, and not sure if declaring mocks as const wont break anything.

Comment on lines 1 to 2
import { beforeEach, afterEach, describe, it, expect, vi, Mock } from "vitest";
import { HawkLocalStorage } from "../../src/storages/hawk-local-storage";
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

This new test uses double quotes in imports, while existing tests in this package consistently use single quotes. Aligning with the established quote style will avoid ESLint churn.

Suggested change
import { beforeEach, afterEach, describe, it, expect, vi, Mock } from "vitest";
import { HawkLocalStorage } from "../../src/storages/hawk-local-storage";
import { beforeEach, afterEach, describe, it, expect, vi, Mock } from 'vitest';
import { HawkLocalStorage } from '../../src/storages/hawk-local-storage';

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@Reversean Reversean force-pushed the refactor/hawk-storage branch 2 times, most recently from 8cbdac2 to cd47f1e Compare February 17, 2026 19:27
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.

2 participants

Comments