Conversation
Fix/analyser output conversion
ENG-1524 ask() took topK positionally, so an options object serialised
into top_k and includeSources was silently dropped. Both
Video.ask and Collection.ask now accept AskOptions, with the
positional form still working.
ENG-1516 playStream() built a player URL and never opened it. Added
utils/openBrowser (with a browser-field counterpart) so every
.play() launches the browser like videodb-python does.
VIDEODB_NO_BROWSER opts out for CI.
ENG-1522 generateStream() short-circuited on streamUrl alone, so search
shots never fetched playerUrl and getEmbedCode() threw despite
autoGenerate: true. Skip the request only when both are known.
Needs the same one-line change in videodb-python shot.py:88.
ENG-1518 parseFloat(null) produced NaN for videoLength. Coerce through a
finite-number helper and type videoLength/videoTitle optional.
ENG-1512 doc.streamLink ?? doc.streamUrl fell through a real null onto a
key the server never emits, so JSON.stringify dropped streamUrl.
Use || and normalise absent streams to null, matching Python.
Adds test/regressions.spec.ts covering all of the above plus ENG-1517's
scene_id casing, and a jest moduleNameMapper for the @/* alias.
ask() took topK positionally, so an options object serialised into top_k and includeSources was silently dropped. Video.ask and Collection.ask now accept AskOptions, with the positional form still working. generateStream() short-circuited on streamUrl alone, so search shots never fetched playerUrl and getEmbedCode() threw despite autoGenerate: true. Skip the request only when both are already known. parseFloat(null) produced NaN for videoLength. Coerce through a finite-number helper and type videoLength/videoTitle as optional. doc.streamLink ?? doc.streamUrl fell through a real null onto a key the server never emits, so JSON.stringify dropped streamUrl. Use || and normalise absent streams to null, matching videodb-python. Folded into the unreleased 0.3.1 CHANGELOG entry; 0.3.0 is npm latest.
…-db/videodb-node into fix/understand-issue-fixes
fix: search, ask, and stream metadata regressions
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.
Pull Request
Description:
Fixes four regressions in the Search v2 surface, all found while exercising
search()→Shot→getEmbedCode()end to end. Three come from the server sending shapes the SDK's types did not allow (length: null, absenttitle, explicitnullstream keys); the fourth is anask()signature that could not accept the options object its own docs implied. Behaviour is aligned withvideodb-pythonin each case.No version bump:
0.3.1is still unpublished (npmlatestis0.3.0), so these entries fold into the existing[0.3.1]CHANGELOG section rather than opening a[0.3.2].Changes:
ask()accepts an options object —Video.ask()/Collection.ask()now takeAskOptions(topK,mode,includeSources) as the second argument. Previously that parameter wastopK: number, so an options object was serialised straight intotop_kandmode/includeSourceswere dropped without error. The positional form still works;AskOptionsis exported from@/types/searchgetEmbedCode({ autoGenerate: true })works on search shots —generateStream()returned early whenstreamUrlalone was set, so shots from search never fetchedplayerUrlandgetEmbedCode()threw despite auto-generation. It now skips the request only when both URLs are known, and sendslength: nullfor shots with no video length instead of lettingJSON.stringifycoerceNaNvideoLengthis no longerNaN—parseFloat(result.length)producedNaNwhen Search v2 sentlength: null; values now pass through a finite-number coercion returningundefinedfor null/empty/non-numeric inputstreamUrlis no longer dropped from serialised shots —doc.streamLink ?? doc.streamUrlfell through a realnullonto a key the server never emits, leavingundefinedsoJSON.stringify()omitted the field. Now uses||and normalises absent streams tonullvideoLength/videoTitleoptional andstreamUrl/playerUrlnullable onShotandShotBase;SearchResponseallowslength: string | number | nullandtitle: string | null[0.3.1]Related Issues:
Testing:
npx tsc --noEmit— passes (exit 0). This carries real signal here, since theShotBase/SearchResponsewidenings are the fix for three of the four bugsnpx jest— passes, but only exercises the pre-existingtest/index.spec.tsplaceholder; it covers none of thisvideo.ask('...', { topK: 5, includeSources: true })→ confirm the request body carriestop_k: 5andinclude_sources: true, and that the positional formask('...', 5, 'default', true)still produces the same bodycollection.search(...)on an indexed video → take a returnedShot, callgetEmbedCode({ autoGenerate: true }), confirm it returns an iframe rather than throwingplayer_url not availablevideoLengthisundefined(neverNaN) and thatJSON.stringify(shot)still contains astreamUrlkey —nullwhen there is no streamVideo.ask/Collection.ask, and anything consumingShot.videoLength/videoTitle/streamUrl/playerUrl, since those four are now optional or nullableChecklist: