Skip to content

WEBDEV-8510: Migrate metadata-service into elements#54

Open
jbuckner wants to merge 3 commits into
WEBDEV-8509-migrate-item-metadatafrom
WEBDEV-8510-migrate-metadata-service
Open

WEBDEV-8510: Migrate metadata-service into elements#54
jbuckner wants to merge 3 commits into
WEBDEV-8509-migrate-item-metadatafrom
WEBDEV-8510-migrate-metadata-service

Conversation

@jbuckner
Copy link
Copy Markdown
Collaborator

@jbuckner jbuckner commented May 27, 2026

Summary

Moves @internetarchive/metadata-service into src/services/metadata-service/ — the terminal node of the consolidation chain.

⚠️ Stacked on #53 (WEBDEV-8509-migrate-item-metadata), which is stacked on #51. Effectively depends on field-parsers + item-metadata + result-type being in tree. The src/types/result.ts file in this PR is the same content as #52 — once #52 lands first, the rebase here will collapse that file to a no-op.

Changes

  • src/services/metadata-service/metadata-service.ts, metadata-service-interface.ts, metadata-service-error.ts, backend/{default-metadata-backend,metadata-backend-interface}.ts, responses/metadata-response.ts.
  • Import rewrites:
    • @internetarchive/result-type@src/types/result
    • @internetarchive/iaux-item-metadata barrel → individual @src/models/item-metadata/{file,metadata,review,speech-music-asr-entry} imports
  • src/services/metadata-service/metadata-service-error.tsenum MetadataServiceErrorTypeconst … as const + type alias (for erasableSyntaxOnly). String values are unchanged, so all existing equality checks still pass.
  • src/types/result.ts — included to make this branch build standalone; will collapse to a no-op once WEBDEV-8508: Migrate result-type into elements #52 lands on main.
  • Tests — 11 new vitest tests across the service and default-backend. Two trims from the original:
    • The MockResponseGenerator class became a single inline generateMockMetadataResponse function — the test only used a tiny subset of the original mock data.
    • The default-backend tests now restore window.fetch via afterEach instead of per-test backup/restore.

Verification

  • npm run build
  • npm run test ✓ — 283 tests pass (11 new for metadata-service)
  • npm run circular

Order in the migration chain

Test plan

  • Build green
  • All 283 tests pass (11 new)
  • No circular deps
  • Reviewer: confirm the inline generateMockMetadataResponse covers the test's needs (only metadata.identifier is asserted in the test that uses it)
  • Reviewer: confirm the MetadataServiceErrorType const-object preserves string values used by callers (type === MetadataServiceErrorType.networkError should still work everywhere)

🤖 Generated with Claude Code

jbuckner and others added 3 commits May 27, 2026 14:10
Moves @internetarchive/metadata-service into src/services/metadata-service/.
Rewrites field-parsers / iaux-item-metadata / result-type imports to the
in-tree @src/* paths landed by WEBDEV-8507, WEBDEV-8508, WEBDEV-8509.

The MetadataServiceErrorType enum became a const object to satisfy
erasableSyntaxOnly. Tests ported to vitest; default-backend tests
restore window.fetch via afterEach instead of inline try/finally.

The mock-response-generator helper was inlined into the test file
(reduced to a single small function) to avoid shipping a test helper
in the published dist.

Also brings in src/types/result.ts from WEBDEV-8508 since this branch
is stacked on 8509 (which is stacked on 8507) — when 8508 lands first,
this commit's result.ts becomes a no-op via rebase.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The migrated metadata-service test mocks declared interface params
(identifier/keypath, fetch input) they don't use. The source repo silenced
this via eslint-disable, but elements' tsc build has noUnusedParameters on
and TS6133 isn't covered by that eslint comment. Prefix the intentionally
unused params with _ so the build passes while keeping the mock signatures.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

PR Preview Action v1.8.1

🚀 View preview at
https://internetarchive.github.io/elements/pr/pr-54/

Built to branch ghpages at 2026-05-28 21:13 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Copy link
Copy Markdown

@bfalling bfalling left a comment

Choose a reason for hiding this comment

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

LGTM

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