Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5d4c312
feat: introduce in-memory and SQLite store implementations for cachin…
AllyMurray Jul 5, 2025
f881174
chore: update .gitignore to exclude dist directory
AllyMurray Jul 5, 2025
3654098
feat: add TypeScript type safety rules documentation
AllyMurray Jul 5, 2025
de5d68e
chore: update TypeScript type safety rules documentation
AllyMurray Jul 5, 2025
f350b33
feat: add pnpm package manager rules documentation
AllyMurray Jul 5, 2025
31fe507
chore: update pnpm and TypeScript type safety rules documentation
AllyMurray Jul 5, 2025
35191be
chore: refactor ESLint configuration and remove legacy files
AllyMurray Jul 5, 2025
5b4e73a
refactor: enhance TypeScript type safety in tests
AllyMurray Jul 5, 2025
41eded1
refactor: standardize array type syntax across the codebase
AllyMurray Jul 5, 2025
e6e3189
feat: add ESLint rule for array type syntax and remove obsolete test …
AllyMurray Jul 5, 2025
1447c22
refactor: update package references to new repository structure
AllyMurray Jul 5, 2025
37e951f
refactor: enhance type safety by implementing ResourceInterface
AllyMurray Jul 5, 2025
1e5723f
Changes from background composer bc-0d14f884-813c-4566-8c2a-879c86b1508d
cursoragent Jul 5, 2025
3cadae7
Merge pull request #10 from AllyMurray/cursor/refactor-http-client-fo…
AllyMurray Jul 7, 2025
cb1579a
Merge commit '3cadae7c4799ed5cad1353afad58d0c3d432f903' into request-…
AllyMurray Jul 7, 2025
62ded22
chore: add .notes to .gitignore
AllyMurray Jul 7, 2025
bc5bdd7
fix: reorder imports in comic-vine-stores.test.ts and http-client.ts
AllyMurray Jul 7, 2025
8124669
docs: improve JSDoc comments in HttpClientOptions interface
AllyMurray Jul 7, 2025
9c0ec71
fix: correct regex pattern in extractResourceType method
AllyMurray Jul 7, 2025
ec90b60
refactor: enhance test structure and type safety in comic-vine-stores…
AllyMurray Jul 7, 2025
877ab66
feat: add RateLimitConfig type and update imports for rate limiting
AllyMurray Jul 7, 2025
ef9e432
feat: introduce DEFAULT_RATE_LIMIT constant for rate limiting
AllyMurray Jul 7, 2025
c70cac0
refactor: remove REFACTORING_SUMMARY.md as part of project cleanup
AllyMurray Jul 7, 2025
3765c06
refactor: remove vitest types from tsconfig files
AllyMurray Jul 7, 2025
77574b2
refactor: improve type safety in rate limit store tests
AllyMurray Jul 7, 2025
4048d42
refactor: update better-sqlite3 dependency and clean up code
AllyMurray Jul 8, 2025
59a14de
refactor: enhance SQLite store implementations for better type safety…
AllyMurray Jul 8, 2025
9d2f0b7
feat: add memory-managed cache usage example and enhance InMemoryCach…
AllyMurray Jul 8, 2025
bdb96fa
refactor: simplify job count retrieval in SQLiteDedupeStore
AllyMurray Jul 8, 2025
4e4d2ab
refactor: enhance type safety in cache and dedupe store interfaces
AllyMurray Jul 8, 2025
253e2b3
refactor: improve type handling in URL builder and SQLiteCacheStore
AllyMurray Jul 8, 2025
4d313f0
feat: integrate fast-safe-stringify for improved serialization in cac…
AllyMurray Jul 8, 2025
6d84005
refactor: improve database size calculation and result handling in SQ…
AllyMurray Jul 8, 2025
6aa24d7
feat: implement size guard for cache entries in SQLiteCacheStore
AllyMurray Jul 8, 2025
2f6ce28
feat: enhance request hashing to treat numeric and string parameters …
AllyMurray Jul 8, 2025
40deb47
feat: implement abortable wait for rate-limited requests in HttpClient
AllyMurray Jul 8, 2025
4d5435b
chore: add fast-safe-stringify dependency to pnpm-lock.yaml
AllyMurray Jul 8, 2025
ef6c348
feat: enhance InMemoryCacheStore with memory management features
AllyMurray Jul 8, 2025
b342f70
feat: allow graceful exit for InMemoryCacheStore cleanup timer
AllyMurray Jul 8, 2025
1fd34d2
feat: add unref method to cleanup interval in SQLiteCacheStore and SQ…
AllyMurray Jul 8, 2025
31cedc0
fix: update parameter type in HttpClient to ensure string consistency
AllyMurray Jul 8, 2025
dbcf4b0
feat: enhance SQLite stores with connection management options
AllyMurray Jul 9, 2025
dcb5c7a
feat: update README and in-memory store documentation for enhanced cl…
AllyMurray Jul 9, 2025
4a36ce5
refactor: update ComicVine client constructor to use object-based opt…
AllyMurray Jul 10, 2025
0b72641
feat: add CLAUDE.md for development guidance and architecture overview
AllyMurray Jul 21, 2025
9257606
fix: resolve build test failures across all packages
AllyMurray Jul 21, 2025
f219975
feat: expand README with comprehensive API usage and TypeScript suppo…
AllyMurray Jul 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .cursor/rules/pnpm-package-manager.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
description: Always use pnpm for package management in this project
globs: ['package.json', 'pnpm-lock.yaml', '**/*.ts', '**/*.js', '**/*.md']
alwaysApply: true
---

# Package Manager Rules

## Always use pnpm instead of npm or yarn

- Use `pnpm install` instead of `npm install`
- Use `pnpm run <script>` instead of `npm run <script>`
- Use `pnpm test` instead of `npm test`
- Use `pnpm add <package>` instead of `npm install <package>`
- Use `pnpm remove <package>` instead of `npm uninstall <package>`

## Project Context

- This is a TypeScript library for the Comic Vine API
- The project uses Vitest for testing
- The project has both CommonJS and ESM builds
- Always respect the existing code structure and patterns
- When suggesting terminal commands, always use pnpm commands
93 changes: 93 additions & 0 deletions .cursor/rules/typescript-type-safety.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
description: Always use TypeScript types and avoid using any or unknown unless necessary
globs: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx']
alwaysApply: true
---

# TypeScript Type Safety Rules

## Type Safety Rules

### Never use `any` type

- Always use proper TypeScript types
- Use `unknown` **only** when the type is genuinely unknown at compile time
- **Never use `unknown` as a way to bypass type safety** - always use proper type narrowing
- Use union types when multiple types are possible
- Use generics when types need to be parameterized
- Use type assertions sparingly and only when absolutely necessary

### Never use forceful casting

- Avoid using `as` type assertions unless absolutely necessary
- **Never cast from `unknown` without proper type checking first**
- Use type guards instead of casting
- Use proper type narrowing techniques
- If casting is unavoidable, add detailed comments explaining why

### Preferred approaches:

- Use `unknown` **only** when you truly don't know the type (e.g., JSON.parse, external APIs)
- **Always narrow `unknown` types using type guards** before using them
- Use type guards: `if (typeof x === 'string')`
- Use `in` operator: `if ('property' in obj)`
- Use `instanceof` checks: `if (obj instanceof SomeClass)`
- Use discriminated unions with literal types
- Use proper generic constraints

### Examples of what NOT to do:

```typescript
// ❌ Don't use any
function badFunction(param: any): any {}

// ❌ Don't forcefully cast
const result = data as SomeType;

// ❌ Don't use unknown as a type escape hatch
function badUnknownUsage(data: unknown): SomeType {
return data as SomeType; // This defeats the purpose of unknown!
}

// ❌ Don't use unknown when you know the type
function badParameterType(param: unknown): string {
// If you know it should be a string, type it as string!
return param as string;
}
```

### Examples of what TO do:

```typescript
// ✅ Use unknown with proper type narrowing
function goodFunction(param: unknown): string {
if (typeof param === 'string') {
return param;
}
throw new Error('Expected string');
}

// ✅ Use proper generics when types are known
function genericFunction<T>(param: T): T {
return param;
}

// ✅ Use unknown for truly unknown data (like JSON parsing)
function parseApiResponse(jsonString: string): User | null {
const data: unknown = JSON.parse(jsonString);

// Proper type checking before using
if (
typeof data === 'object' &&
data !== null &&
'id' in data &&
'name' in data &&
typeof data.id === 'number' &&
typeof data.name === 'string'
) {
return { id: data.id, name: data.name };
}

return null;
}
```
117 changes: 0 additions & 117 deletions .eslintrc.json

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/build.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .github/workflows/release.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx lint-staged
pnpm pre-commit
77 changes: 77 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Development Commands

### Package Management

- Always use `pnpm` instead of npm or yarn
- Install dependencies: `pnpm install`
- Build all packages: `pnpm run build`
- Run tests: `pnpm run test`
- Run linting: `pnpm run lint`
- Fix linting issues: `pnpm run lint:fix`
- Format code: `pnpm run format`

### Development Workflow

- Pre-commit checks: `pnpm run pre-commit`
- Parallel development: `pnpm run dev`
- Clean build artifacts: `pnpm run clean`
- Release workflow: `pnpm run changeset` → `pnpm run version-packages` → `pnpm run release`

## Architecture Overview

This is a TypeScript monorepo for the Comic Vine API client library with the following structure:

### Core Packages

- **`packages/client`** - Main Comic Vine API client with resource classes, HTTP client, and type definitions
- **`packages/in-memory-store`** - In-memory implementations of cache, deduplication, and rate limiting stores
- **`packages/sqlite-store`** - SQLite-based persistent store implementations
- **`packages/eslint-config`** - Shared ESLint configurations
- **`packages/tsup-config`** - Shared build configurations
- **`packages/vitest-config`** - Shared test configurations

### Key Architecture Patterns

#### Resource-Based API Structure

- Each Comic Vine resource (character, issue, volume, etc.) has its own class in `packages/client/src/resources/`
- Resources inherit from `BaseResource` and implement `list()` and `retrieve()` methods
- Type definitions are organized by resource with separate types for list items and detail responses

#### Store Pattern for Cross-Cutting Concerns

- **Cache Store**: Implements caching with TTL support
- **Dedupe Store**: Prevents duplicate concurrent requests
- **Rate Limit Store**: Handles API rate limiting per resource type
- Stores can be swapped between in-memory and SQLite implementations

#### HTTP Client Architecture

- `HttpClient` handles all API communication with built-in retry logic
- `UrlBuilder` constructs Comic Vine API URLs with proper parameter formatting
- `HttpClientFactory` creates clients with appropriate store configurations

### TypeScript Conventions

- Never use `any` type - always use proper TypeScript types
- Use `unknown` only when genuinely unknown (e.g., JSON parsing) and always narrow with type guards
- Avoid type assertions (`as`) - use type guards instead
- All resources have detailed type definitions for both list and detail responses

### Testing Strategy

- Uses Vitest for all testing
- Comprehensive test coverage with mocked API responses in `__mocks__/`
- Each resource and utility has corresponding `.test.ts` files
- Tests focus on type safety, error handling, and API contract compliance

### Build System

- Uses Turbo for monorepo management
- Dual ESM/CJS builds via tsup
- Automatic type generation with TypeScript
- Changesets for version management and publishing
Loading