Fix TypeScript errors in generated lexicon code (#30)
* chore: remove spike package and references
Remove the spike package which was used for early PDS testing but is no longer needed. Updates all documentation references in CLAUDE.md, README.md, environment files, and planning docs.
Changes:
- Delete packages/spike directory
- Update CLAUDE.md: remove spike from packages table and commands
- Update README.md: remove spike from packages table
- Update .env.example and .env.production.example
- Update docs: atproto-forum-plan.md, oauth-implementation-summary.md, write-endpoints-design.md
- Update pnpm-lock.yaml via pnpm install
* fix: resolve TypeScript errors in generated lexicon code
Fixes the 29 TypeScript compilation errors in packages/lexicon by:
1. Adding missing @atproto dependencies:
- @atproto/xrpc@^0.7.7 for XrpcClient imports
- @atproto/api@^0.15.0 for ComAtprotoRepo* namespace types
2. Automating the fix with build:fix-generated-types script:
- Runs after lex gen-api generates TypeScript
- Injects missing import statements for ComAtprotoRepo* types
- Idempotent (safe to run multiple times)
3. Removing error suppression from build:compile script:
- Compilation now succeeds without fallback echo
The @atproto/lex-cli code generator references standard AT Protocol
namespaces (ComAtprotoRepoListRecords, ComAtprotoRepoGetRecord, etc.)
but doesn't import them. This is expected behavior - generated clients
are meant to consume @atproto/api which provides these types.
Before: 29 TypeScript errors, CI allowed to fail
After: Clean compilation, all tests pass
* docs: remove TypeScript error warnings after fix
Updates documentation to reflect that the 29 TypeScript errors in
generated lexicon code have been resolved:
- Remove 'Known Issues' section from CLAUDE.md
- Update CI workflow description to remove error allowance note
- Remove continue-on-error from typecheck job in ci.yml
The typecheck hook and CI job now enforce zero TypeScript errors.
* refactor: address PR review feedback on fix-generated-types script
Addresses all critical issues from PR #30 review:
## Test Coverage (Issue #1 - Severity 9/10)
- Added comprehensive test suite with 10 test cases
- Covers success paths, error cases, idempotency, and edge cases
- Tests validate: clean generation, duplicate prevention, whitespace
tolerance, missing file errors, pattern mismatches, and more
- All tests passing (10/10)
## Robust Pattern Matching (Issue #2 - Severity 9/10)
- Replaced brittle string matching with regex: ANCHOR_IMPORT_REGEX
- Handles whitespace variations and optional .js extensions
- Clear error message when pattern doesn't match
- Resilient to @atproto/lex-cli format changes
## Accurate Idempotency Check (Issue #3 - Severity 8/10)
- Fixed overly broad check that looked for ANY @atproto/api import
- Now checks for ALL 5 specific required types
- Prevents false positives if lex-cli adds other imports
- Uses regex to verify exact type imports
## Replacement Validation (Issue #4 - Severity 8/10)
- Validates that string replace() actually modified content
- Confirms all required imports are present after injection
- Throws clear errors if validation fails
- Prevents silent failures
## Specific Error Messages (Issue #5 - Severity 8/10)
- Distinguishes ENOENT (file missing) from EACCES (permission denied)
- Provides actionable recovery instructions for each error
- Clear messages when generator format changes
- Includes context in all error paths
## Correct Dependency Placement (Issue #6)
- Moved @atproto/api and @atproto/xrpc to devDependencies
- Only needed at build time, not runtime
- Reduces published package size
## Enhanced Documentation (Issue #7)
- Expanded JSDoc comment explaining WHY workaround exists
- Documents WHEN it might break (format changes)
- Provides HOW to fix when it breaks
- Added maintenance guidance for future updates
All improvements verified with comprehensive test suite.
* fix: move @atproto/api and @atproto/xrpc to dependencies
These packages are imported in the generated dist/types/index.js
at runtime, so they must be runtime dependencies, not devDependencies.
The lockfile already had them as dependencies, but package.json had
them in devDependencies, causing CI frozen-lockfile check to fail.
* debug: add verification step to check lexicon build outputs
Add diagnostic step to verify that lexicon dist files are created
before tests run. This will help debug the CI module resolution error.
* fix: refresh workspace links after build
Add pnpm install step after build to ensure workspace package links
are correctly updated when Vitest runs. This should resolve the
module resolution error in CI while tests pass locally.
* fix: add Vite resolve alias for workspace packages
Configure Vite to explicitly resolve @atbb/lexicon workspace package
imports. This works around a CI-specific module resolution issue where
Vite cannot find workspace package files even though they exist.
The alias ensures Vite resolves workspace imports directly to the
package dist directory, bypassing the workspace symlink resolution
that fails in CI but works locally.
* refactor: use main package exports instead of deep imports
Replace deep import paths (@atbb/lexicon/dist/types/...) with imports
from the main package export (@atbb/lexicon). The generated index.ts
already re-exports all types as named exports.
This avoids the CI module resolution issue where Vite couldn't find
deep import paths in the workspace package structure. Using the main
package export is cleaner and more maintainable.
* fix: revert to deep imports with proper namespace types
Revert to the original deep import style which provides proper
TypeScript namespace support for helper functions like isReplyRef.
Testing if the earlier CI fixes (pnpm install refresh, Vite alias)
combined with the dependency placement fix resolves the module
resolution issue.
* feat: add clean export paths for lexicon types
Add explicit package.json exports for common types:
- @atbb/lexicon/post
- @atbb/lexicon/forum
- @atbb/lexicon/category
- @atbb/lexicon/membership
- @atbb/lexicon/mod-action
This provides clean, readable import paths that work correctly in
both local development and CI, avoiding the workspace module resolution
issues with deep import paths while maintaining proper TypeScript
namespace support.
* fix: use conditional exports for proper Vite module resolution
- Add 'types' condition to package exports to help Vite resolve TypeScript definitions
- Specify 'import' and 'default' conditions for ESM module resolution
- Modern package.json pattern required for proper TypeScript + Vite support
- Fixes 'Cannot find module' error in CI test runs
* debug: add more diagnostics to investigate CI module resolution failure
- Show package.json exports in CI logs
- Test if Node can import the module successfully
- This will help identify the difference between local (works) and CI (fails)
* fix: resolve TypeScript errors in generated lexicon code
- Add build step to inject @atproto/api imports into generated types
- Use deep import paths for lexicon types (simpler and more reliable)
- Move @atproto/api and @atproto/xrpc to dependencies (runtime imports)
This fixes the 23 TypeScript errors in generated lexicon code that
occurred because @atproto/lex-cli generates files without importing
the types they reference from @atproto/api.
* fix: add Vite resolve.alias to fix module resolution in CI
- Use regex-based alias to map @atbb/lexicon imports to physical paths
- This resolves Vite module resolution issues in CI environments
- Deep import paths work locally and in CI with explicit path mapping
* chore: install vite-tsconfig-paths so that vite can resolve lexicon files
* chore: wild attempt to get ci to work
* fix: resolve TypeScript errors in generated lexicon code
Copy generated lexicon files to appview package and use local Vite aliases instead of workspace imports. Fixes all 32 TypeScript errors.
Changes: Updated copy script to exclude .ts files, added @atproto/lexicon and @atproto/xrpc deps, added __generated__/ to .gitignore
All 371 tests passing (db: 40, lexicon: 53, web: 20, appview: 258)
* fix: use package entry point for lexicon type imports
Replace @lexicons/* path aliases (only resolved by Vitest, invisible to
tsc) with named re-exports from the @atbb/lexicon package entry point.
The generated index.ts already re-exports all type namespaces — this is
the intended consumption pattern for @atproto/lex-cli output.
Removes the copy-to-appview build step, fix-copied-imports script,
@lexicons vitest alias, and unused appview dependencies that only
existed to support the file-copying approach.