WEBDEV-8920: Add fetchMetadataField for modeled single-field lookups - #18
Open
jbuckner wants to merge 4 commits into
Open
WEBDEV-8920: Add fetchMetadataField for modeled single-field lookups#18jbuckner wants to merge 4 commits into
jbuckner wants to merge 4 commits into
Conversation
fetchMetadataValue hands back the raw API value, so callers that want a modeled
field construct one themselves. Reading an item's primary collection meant
`new StringField(raw).value`, and the reason it needs a field at all is easy to
miss: collection is a list on an item in several collections but a bare string
on an item in one, so reading [0] is wrong half the time.
Takes a field name rather than a field class, and derives both the class and
the return type from Metadata's own getter, so the mapping from field name to
field type isn't duplicated here and a field added to Metadata is available
without a change in this package. MetadataFieldKey is derived the same way, so
only real fields are reachable — identifier and rawMetadata aren't.
const result = await metadataService.fetchMetadataField('bra-bfr', 'collection');
result.success?.value; // 'kodi_archive'
Rejects a value that isn't a scalar or array of scalars, which would otherwise
construct a field whose String() is '[object Object]' inside a successful
result.
Note for consumers: this is a required member of MetadataServiceInterface, so
anything implementing that interface has to add it. Offshoot's
MockMetadataService does.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GxnijHsZmBrHkcuJ5XYf9
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
==========================================
- Coverage 93.14% 90.67% -2.48%
==========================================
Files 4 4
Lines 321 386 +65
Branches 28 38 +10
==========================================
+ Hits 299 350 +51
- Misses 18 32 +14
Partials 4 4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
It's derived from Metadata and describes Metadata's shape, so it belongs in iaux-item-metadata rather than here. Leaving it unexported means moving it there is an internal refactor instead of a breaking removal. Calling fetchMetadataField with a field-name literal doesn't need the name. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GxnijHsZmBrHkcuJ5XYf9
* origin/main: WEBDEV-8921: Gitignore .claude/worktrees (#17)
The type lives next to Metadata now (WEBDEV-8923), so drop the local copy and take it from the package. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019VzfA4RksuDWvNvUq5oQgm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fetchMetadataValuereturns the raw API value, so callers wanting a modeled field build one themselves. The motivating case:collectionis a list on an item in several collections but a bare string on an item in one, so reading[0]is wrong half the time.Takes a field name, not a field class, and derives both the runtime class and the return type from
Metadata's own getter. So the field-name-to-field-type mapping isn't duplicated here, and a field added toMetadataworks without a change in this package.addeddatecomes back as aDatewithout being told to.MetadataFieldKeyis derived the same way, so only real fields are reachable (identifierandrawMetadataare rejected at compile time). It comes from iaux-item-metadata 1.5.0, where it landed on WEBDEV-8923.Also rejects a value that isn't a scalar or array of scalars, which would otherwise construct a field whose
String()is'[object Object]'inside a successful result.Heads up for consumers: required member on
MetadataServiceInterface, so implementors must add it. Offshoot'sMockMetadataServicedoes — that lands with the version bump there.🤖 Generated with Claude Code
https://claude.ai/code/session_017GxnijHsZmBrHkcuJ5XYf9