Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Jul 18, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.3)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Introduce comprehensive enhancements to the SDK’s streaming, caching, migration, tree utilities, error handling, and type definitions, alongside build and CI updates.

New Features:

  • Add tree conversion utilities (filesToTree, treeToFiles, findNodeByPath, walkTree, sortTree, filterTree, calculateTreeMetrics)
  • Introduce streaming APIs and markdown generators (streamGitHubFiles, createMarkdownStream, createTransformStream, collectStream, filterStream, mapStream)
  • Add caching support with fetchFromWebCached, createCacheStorage, deleteFromCache, clearCache, and withCache decorator
  • Provide migration helpers and compatibility layer for v1 to v2 (migrateFromV1, compat, generateMigrationGuide, needsMigration, autoMigrateCode)

Enhancements:

  • Enhance error handling with CodefetchError base class and specialized errors (GitHubError, TokenLimitError, ParseError, NetworkError, ConfigError, CacheError, URLValidationError) plus type guards
  • Augment FetchMetadata and FileContent types with performance metrics, Git info, language/mimeType/encoding fields and add validation helpers (isValidGitHubUrl, isValidRepoPath, isValidSemVer, createGitHubToken, createRepoPath, createGitHubUrl)
  • Refine utility logic (use Number.isNaN, String.fromCodePoint, updated htmlToMarkdown, improved URL and IP validation)
  • Unify exports and update entry points in worker and browser builds

Build:

  • Disable fail-on-warn in build.config
  • Exclude test/worker-runtime-test.ts from TS compilation

CI:

  • Add GitHub Actions workflow to publish PR previews

Chores:

  • Add @cloudflare/workers-types dev dependency
  • Update pnpm lockfile with new worker types

regenrek added 5 commits July 18, 2025 09:11
…trics

- Added `@cloudflare/workers-types` as a devDependency for improved type support.
- Introduced `PerformanceMetrics` interface to track performance metrics in `FetchMetadata`.
- Updated `FileContent` interface to include optional properties for better file handling.
- Adjusted `build.config.ts` to disable warnings during build.
- Enhanced type definitions across various files for improved usability and maintainability.

These changes improve the SDK's type definitions and enhance its functionality for developers working with Cloudflare Workers.
@pull pull bot locked and limited conversation to collaborators Jul 18, 2025
@pull pull bot added the ⤵️ pull label Jul 18, 2025
@pull pull bot merged commit 065a790 into admariner:main Jul 18, 2025
8 checks passed
Copy link

@giga-agent giga-agent bot left a comment

Choose a reason for hiding this comment

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

Detailed code review comments

return parts.every((part) => {
const num = Number.parseInt(part, 10);
return !isNaN(num) && num >= 0 && num <= 255 && part === num.toString();
return !Number.isNaN(num) && num >= 0 && num <= 255 && part === num.toString();
Copy link

Choose a reason for hiding this comment

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

Good improvement: Using Number.isNaN() instead of global isNaN() is more precise and safer

const size = Number.parseInt(sizeStr, 8);
const typeFlag = String.fromCharCode(block[156]);
const typeFlag = String.fromCodePoint(block[156]);
return {
Copy link

Choose a reason for hiding this comment

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

Good update: fromCodePoint() is more modern and has better Unicode support than fromCharCode()

private url: string;
private result: FetchResult;
root: FileNode;
url: string;
Copy link

Choose a reason for hiding this comment

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

Changing private fields to public may break encapsulation. Consider if this is intentional

// Check if expired
const metadata = await kv.getWithMetadata(key);
if (metadata.metadata?.expires) {
if (
Copy link

Choose a reason for hiding this comment

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

Good enhancement to add type checking for metadata object structure, making the code more type-safe

if (cacheStorage.type === "cache-api") {
const cache = cacheStorage.instance as Cache;
const _cache = cacheStorage.instance as Cache;
// Cache API doesn't support listing, so we can't clear by pattern
Copy link

Choose a reason for hiding this comment

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

Unused variable renamed with underscore prefix, but consider removing it entirely if not used

return parts.every((part) => {
const num = Number.parseInt(part, 10);
return !isNaN(num) && num >= 0 && num <= 255 && part === num.toString();
return (
Copy link

Choose a reason for hiding this comment

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

Good change replacing isNaN() with Number.isNaN() for more precise NaN checking

declaration: true,
clean: true,
failOnWarn: false,
externals: [
Copy link

Choose a reason for hiding this comment

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

Disabling build warnings could hide potential issues. Consider handling warnings instead of suppressing them.

*/

// @ts-ignore - importing from built file
import {
Copy link

Choose a reason for hiding this comment

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

Avoid using @ts-ignore. Consider fixing the underlying import issue or using @ts-expect-error with explanation if absolutely necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant