Skip to content

Convert providers/harvest/ to TypeScript - #1548

Merged
JamieMagee merged 6 commits into
masterfrom
ts-providers/harvest
Apr 13, 2026
Merged

JamieMagee merged 6 commits into
masterfrom
ts-providers/harvest

Conversation

@JamieMagee

@JamieMagee JamieMagee commented Apr 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge 9 .js + .d.ts pairs into .ts in providers/harvest/ (incl. throttling).

Review commit-by-commit: renames, import paths, type merges.

@JamieMagee JamieMagee changed the title ts providers/harvest Convert providers/harvest/ to TypeScript Apr 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Converts the providers/harvest/ area from paired .js + .d.ts modules into native .ts implementations and updates runtime/test import paths accordingly (including harvest throttling and crawler queue components).

Changes:

  • Replaced multiple providers/harvest/** .js + .d.ts pairs with .ts sources and migrated JSDoc typedefs to TypeScript types/interfaces.
  • Updated application/provider wiring (app.js, providers/index.js) and test imports to reference the new .ts modules.
  • Introduced/ported the cache-based harvester implementation to TypeScript (providers/harvest/cacheBasedCrawler.ts) and removed legacy JS/DTs counterparts.
Show a summary per file
File Description
test/routes/harvest.ts Updates throttling import to the new .ts module.
test/providers/harvest/throttling/listBasedFilterTest.ts Updates import path to .ts throttling filter.
test/providers/harvest/throttling/listBasedFilterConfigTest.ts Updates esmock target to .ts config module.
test/providers/harvest/processTest.ts Updates import to .ts harvest processor.
test/providers/harvest/crawlerConfig.ts Updates esmock targets for crawler config/crawler modules to .ts.
test/providers/harvest/cacheBasedCrawlerTest.ts Updates import to .ts cache-based crawler/harvester.
providers/index.js Switches harvest provider imports (and throttler config) to .ts modules.
providers/harvest/throttling/listBasedFilterConfig.ts Converts config factory to TS types and imports the .ts filter.
providers/harvest/throttling/listBasedFilterConfig.d.ts Removed (types now live in .ts).
providers/harvest/throttling/listBasedFilter.ts Converts filter implementation and options typing to TypeScript.
providers/harvest/throttling/listBasedFilter.d.ts Removed (types now live in .ts).
providers/harvest/process.ts Converts harvest queue processor to TS, adds typed imports and additional guards.
providers/harvest/process.d.ts Removed (types now live in .ts).
providers/harvest/crawlerQueueConfig.ts Converts crawler-queue service factory to TS and adds option typing.
providers/harvest/crawlerQueueConfig.d.ts Removed (types now live in .ts).
providers/harvest/crawlerQueue.ts Converts queue-backed harvester to TS and exports typed options/class.
providers/harvest/crawlerQueue.d.ts Removed (types now live in .ts).
providers/harvest/crawlerConfig.ts Converts HTTP crawler service factory to TS and adds option typing.
providers/harvest/crawlerConfig.d.ts Removed (types now live in .ts).
providers/harvest/crawler.ts Converts HTTP crawler harvester to TS and exports typed options/class.
providers/harvest/crawler.d.ts Removed (types now live in .ts).
providers/harvest/cacheBasedCrawler.ts Adds TS implementation for cache-based harvest tracking and concurrency control.
providers/harvest/cacheBasedCrawler.js Removed (replaced by .ts).
providers/harvest/cacheBasedCrawler.d.ts Removed (types now live in .ts).
providers/harvest/azureQueueConfig.ts Converts Azure queue config factory to TS signature.
providers/harvest/azureQueueConfig.d.ts Removed (types now live in .ts).
app.js Updates harvest processing import to the new .ts processor module.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (6)

providers/harvest/throttling/listBasedFilter.ts:28

  • versionlessCoordinates is inferred as (EntityCoordinates | null)[] because .filter(Boolean) is not a type guard under strict TS settings. That makes the subsequent map(c => c.type) / map(c => c.toString()) unsafe and can fail type-checking. Use an explicit type predicate in the filter (e.g., filter to c !== null) so the array is EntityCoordinates[].
    providers/harvest/process.ts:48
  • toolRevision is optional in parseUrn() output, but computeAndStoreIfNecessary requires a string. The non-null assertion (toolRevision!) only silences the compiler and can still pass undefined at runtime, breaking tool-result tracking. Add an explicit if (!toolRevision) { ... } handling (e.g., log + return, or treat as invalid message) before calling computeAndStoreIfNecessary.
    providers/harvest/crawlerQueue.ts:34
  • IQueue.queue() returns a Promise<void>, but the enqueues here are not awaited. As a result, harvest() can resolve before messages are actually written, and any enqueue rejection becomes unhandled. Await the queue() calls (sequentially or via Promise.all) so harvest() only resolves after all messages are queued.
    providers/harvest/crawlerQueueConfig.ts:40
  • initialize() returns a promise on IQueue, but these calls are not awaited. If initialization is asynchronous (e.g., Azure queue), the returned harvester may start using queues before they're ready, and initialization errors will be dropped. Consider making serviceFactory async and awaiting both initializations (or otherwise ensure initialization happens before use).
    providers/harvest/crawlerConfig.ts:26
  • CrawlerConfigOptions requires cachingService, but serviceFactory allows options to be omitted. If serviceFactory() is ever called without args, it will pass undefined cachingService into cacheBasedCrawler(...) and fail at runtime. Consider making options required (or providing a safe default / explicit error) to match the type contract.
    providers/harvest/crawlerQueueConfig.ts:44
  • CrawlerQueueConfigOptions requires cachingService, but serviceFactory declares options?. If called without args, cacheBasedCrawler({ ...options, ... }) will omit cachingService and can throw at construction time. Consider making options required (or explicitly validating and throwing a clear error) to align runtime behavior with the declared options interface.
  • Files reviewed: 18/27 changed files
  • Comments generated: 1

Comment thread providers/harvest/cacheBasedCrawler.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Converts the providers/harvest/ implementation (including throttling and crawler/queue wiring) from paired .js + .d.ts files into consolidated .ts sources, and updates imports across runtime and tests accordingly.

Changes:

  • Update application and test imports to reference the new .ts harvest provider modules.
  • Migrate harvest provider modules (crawler, queue crawler, cache-based crawler, processing, throttling config/filter) to TypeScript and remove corresponding .d.ts files.
  • Introduce explicit TS interfaces/types for harvest provider configuration and harvester contracts.
Show a summary per file
File Description
test/routes/harvest.ts Update throttling filter import to .ts.
test/providers/harvest/throttling/listBasedFilterTest.ts Update throttling filter import to .ts.
test/providers/harvest/throttling/listBasedFilterConfigTest.ts Update esmock target to .ts config module.
test/providers/harvest/processTest.ts Update harvest process import to .ts.
test/providers/harvest/crawlerConfig.ts Update esmock targets for crawler config + crawler modules to .ts.
test/providers/harvest/cacheBasedCrawlerTest.ts Update cache-based crawler import to .ts.
providers/index.js Switch harvest provider imports to .ts modules.
providers/harvest/throttling/listBasedFilterConfig.ts Convert throttler factory/config parsing module to TS and inline types.
providers/harvest/throttling/listBasedFilterConfig.d.ts Removed (types merged into .ts).
providers/harvest/throttling/listBasedFilter.ts Convert throttling filter implementation to TS and inline option types.
providers/harvest/throttling/listBasedFilter.d.ts Removed (types merged into .ts).
providers/harvest/process.ts Convert queue processor to TS and add additional parsing guards.
providers/harvest/process.d.ts Removed (types merged into .ts).
providers/harvest/crawlerQueueConfig.ts Convert queue-crawler config factory to TS and inline option types.
providers/harvest/crawlerQueueConfig.d.ts Removed (types merged into .ts).
providers/harvest/crawlerQueue.ts Convert queue-based harvester to TS and export option types/class.
providers/harvest/crawlerQueue.d.ts Removed (types merged into .ts).
providers/harvest/crawlerConfig.ts Convert HTTP crawler config factory to TS and inline option types.
providers/harvest/crawlerConfig.d.ts Removed (types merged into .ts).
providers/harvest/crawler.ts Convert HTTP crawler harvester to TS and export option types/class.
providers/harvest/crawler.d.ts Removed (types merged into .ts).
providers/harvest/cacheBasedCrawler.ts Add TS implementation for cache-based harvester and its exported types.
providers/harvest/cacheBasedCrawler.js Removed (replaced by .ts).
providers/harvest/cacheBasedCrawler.d.ts Removed (types merged into .ts).
providers/harvest/azureQueueConfig.ts Convert Azure queue config factory to TS (typed options).
providers/harvest/azureQueueConfig.d.ts Removed (types merged into .ts).
app.js Update harvest processor import to .ts.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (3)

providers/harvest/process.ts:43

  • processMessage returns early when coordinates or tool are missing, which skips queue.delete(message) and leaves the message in the queue without any logging. If these cases represent malformed/unsupported events, consider logging a warning and deleting (or dead-lettering) the message to avoid infinite retries/queue buildup.
    providers/harvest/process.ts:48
  • Avoid using the non-null assertion on toolRevision. parseUrn() returns toolRevision?: string, and at runtime this can still be undefined, which then gets passed into computeAndStoreIfNecessary (expects a string) and can break tool-result deduping (e.g., tool/undefined). Validate toolRevision (and decide whether to delete/dead-letter the message) or provide a safe default before calling the definition service.
    providers/harvest/crawler.ts:31
  • The debug log JSON.stringify(headers) includes the X-token auth token. Even at debug level this can leak secrets into logs. Consider removing this log line or redacting/masking the token value before logging.
  • Files reviewed: 18/27 changed files
  • Comments generated: 1

Comment thread providers/harvest/cacheBasedCrawler.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Converts the providers/harvest/ provider set from mixed .js + .d.ts pairs into native .ts modules and updates all internal/test import paths accordingly (including throttling and crawler queue integration).

Changes:

  • Migrated harvest provider modules (crawler, queue harvester, cache wrapper, throttling, process runner, queue config) to TypeScript and removed corresponding .d.ts/.js artifacts.
  • Updated runtime and configuration wiring (app.js, providers/index.js) to import the new .ts harvest modules.
  • Updated tests to import the new .ts harvest modules and config factories.
Show a summary per file
File Description
app.js Switches harvest processing import to the new TypeScript module.
providers/index.js Updates harvest-related provider wiring to import .ts implementations.
providers/harvest/process.ts Converts queue processor to TS and tightens URN parsing/processing types.
providers/harvest/cacheBasedCrawler.ts Introduces TS version of cache-based harvester and consolidates types.
providers/harvest/crawler.ts Converts HTTP crawler harvester to TS with explicit option/types.
providers/harvest/crawlerConfig.ts Converts crawler service factory to TS and merges type definitions.
providers/harvest/crawlerQueue.ts Converts queue-based harvester to TS and merges type definitions.
providers/harvest/crawlerQueueConfig.ts Converts queue crawler service factory to TS and merges type definitions.
providers/harvest/azureQueueConfig.ts Converts harvest queue factory to TS and removes redundant typedefs.
providers/harvest/throttling/listBasedFilter.ts Converts throttling filter to TS and inlines option typings.
providers/harvest/throttling/listBasedFilterConfig.ts Converts throttler factory to TS and removes separate .d.ts.
test/routes/harvest.ts Updates test imports to point at the new TS throttling filter.
test/providers/harvest/processTest.ts Updates test import to new TS harvest processor.
test/providers/harvest/cacheBasedCrawlerTest.ts Updates test import to new TS cache-based crawler.
test/providers/harvest/crawlerConfig.ts Updates esmock wiring to use the TS crawler config & modules.
test/providers/harvest/throttling/listBasedFilterTest.ts Updates test import to TS throttling filter.
test/providers/harvest/throttling/listBasedFilterConfigTest.ts Updates esmock wiring to use TS throttler config.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (3)

providers/harvest/process.ts:48

  • toolRevision from parseUrn() can be undefined (URNs without a tool revision). The non-null assertion (toolRevision!) can hide real runtime cases and will end up passing undefined into computeAndStoreIfNecessary, which expects a string. Add a guard for missing toolRevision (or derive a default) before calling computeAndStoreIfNecessary so the behavior is explicit and safe.
    providers/harvest/crawlerQueueConfig.ts:36
  • options is optional here, but CacheBasedHarvester requires cachingService and serviceFactory will ultimately pass through to cacheBasedCrawler(...). As written, calling serviceFactory() without arguments is allowed by the type signature but will fail at runtime when cachingService is missing. Either make options required, or keep it optional but add an explicit runtime check and throw a clear error when cachingService isn’t provided.
    providers/harvest/crawlerConfig.ts:25
  • options is marked optional, but CrawlerConfigOptions requires cachingService and cacheBasedCrawler(...) will fail if it’s absent. Consider making options required or adding a runtime validation with a clear error message when cachingService is missing, so the API contract matches actual requirements.
  • Files reviewed: 18/27 changed files
  • Comments generated: 1

Comment thread providers/harvest/cacheBasedCrawler.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Converts the providers/harvest/ provider implementations (including throttling and queue/crawler components) from .js + .d.ts pairs into consolidated .ts modules, and updates runtime and test import paths accordingly.

Changes:

  • Replaced Harvest provider .js implementations and accompanying .d.ts files with .ts sources (e.g., crawler, queue crawler, cache-based crawler, throttling filter/config, processing).
  • Updated application and provider registry imports to reference the new .ts modules.
  • Updated unit/integration tests and esmock paths to target the TypeScript modules.
Show a summary per file
File Description
app.js Updates Harvest processor import to the new .ts module.
providers/index.js Points Harvest provider wiring to .ts implementations (crawler, queue crawler, throttler config).
providers/harvest/azureQueueConfig.ts Converts queue config factory typing from JSDoc to TS.
providers/harvest/azureQueueConfig.d.ts Removed (types now live in .ts).
providers/harvest/cacheBasedCrawler.ts New TS implementation replacing prior .js + .d.ts.
providers/harvest/cacheBasedCrawler.js Removed (superseded by .ts).
providers/harvest/cacheBasedCrawler.d.ts Removed (types now live in .ts).
providers/harvest/crawler.ts Converts HTTP crawler harvester to TS with exported types/classes.
providers/harvest/crawler.d.ts Removed (types now live in .ts).
providers/harvest/crawlerConfig.ts Converts crawler service factory to TS and updates imports.
providers/harvest/crawlerConfig.d.ts Removed (types now live in .ts).
providers/harvest/crawlerQueue.ts Converts queue-based harvester to TS with exported types/classes.
providers/harvest/crawlerQueue.d.ts Removed (types now live in .ts).
providers/harvest/crawlerQueueConfig.ts Converts queue crawler factory/config to TS and updates imports.
providers/harvest/crawlerQueueConfig.d.ts Removed (types now live in .ts).
providers/harvest/process.ts Converts harvest queue processing to TS and tightens some runtime guards.
providers/harvest/process.d.ts Removed (types now live in .ts).
providers/harvest/throttling/listBasedFilter.ts Converts throttling filter implementation to TS and inlines options typing.
providers/harvest/throttling/listBasedFilter.d.ts Removed (types now live in .ts).
providers/harvest/throttling/listBasedFilterConfig.ts Converts throttler factory/config parsing to TS.
providers/harvest/throttling/listBasedFilterConfig.d.ts Removed (types now live in .ts).
test/routes/harvest.ts Updates throttler filter import to .ts.
test/providers/harvest/cacheBasedCrawlerTest.ts Updates cache-based crawler import to .ts.
test/providers/harvest/crawlerConfig.ts Updates esmock paths to .ts modules.
test/providers/harvest/processTest.ts Updates harvest process import to .ts.
test/providers/harvest/throttling/listBasedFilterTest.ts Updates filter import to .ts.
test/providers/harvest/throttling/listBasedFilterConfigTest.ts Updates esmock path to .ts.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (4)

providers/harvest/process.ts:48

  • toolRevision can be undefined for URNs that don’t include a tool revision (see parseUrn in lib/utils.ts, which returns split parts as-is). The non-null assertion (toolRevision!) makes this easy to miss and can lead to computeAndStoreIfNecessary being called with undefined at runtime. Please explicitly handle the missing revision (e.g., return early with a warning/log, or derive a default) before calling computeAndStoreIfNecessary.
    providers/harvest/crawlerConfig.ts:24
  • CrawlerConfigOptions requires cachingService, but serviceFactory currently makes options optional. This allows callers to invoke serviceFactory() without providing a cache, which will fail at runtime when cacheBasedCrawler expects cachingService. Consider making options non-optional (or providing a safe default/explicit error when it’s missing).
    providers/harvest/crawlerQueueConfig.ts:37
  • CrawlerQueueConfigOptions requires cachingService, but serviceFactory accepts options?. This makes it possible to call serviceFactory() without the required cache and then pass an invalid options object into cacheBasedCrawler. Please make options required (or throw a clear error when cachingService isn’t provided).
    providers/harvest/throttling/listBasedFilterConfig.ts:12
  • parseListEnv is declared to return string[], but the implementation returns the raw JSON.parse result after only checking Array.isArray. This can include non-string items (numbers/objects), which violates the return type and relies on downstream code to tolerate invalid entries. Please validate/filter the parsed array to strings before returning it (and optionally warn/drop invalid items).
  • Files reviewed: 18/27 changed files
  • Comments generated: 0 new

@qtomlinson qtomlinson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Follow-up suggestion: tighten HarvestEntry.coordinates back to EntityCoordinates

The widening to EntityCoordinates | string is currently needed to accommodate routes/harvest.js:139:

return { ...entry, coordinates: normalized.toString() }

As a follow-up, consider passing the object directly instead:

return { ...entry, coordinates: normalized }

This would allow HarvestEntry.coordinates to be kept as EntityCoordinates only. The POST /harvest route and its unit tests would need to be reviewed and adjusted accordingly.

@JamieMagee
JamieMagee merged commit be54e48 into master Apr 13, 2026
8 checks passed
@JamieMagee
JamieMagee deleted the ts-providers/harvest branch April 13, 2026 22:53
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