Add active_profile_nexus_files query; fix query-type generator#23646
Open
halgari wants to merge 2 commits into
Open
Add active_profile_nexus_files query; fix query-type generator#23646halgari wants to merge 2 commits into
halgari wants to merge 2 commits into
Conversation
Adds pivot tables (profile_settings_pivot, mod_attributes_pivot, mod_state_pivot) and a registered select that lists gameId/modId/fileId for every installed Nexus mod file of the active profile's game. Fixes three latent bugs in scripts/generate-query-types.ts exposed by the first parameterless select: stale halgari.github.io extension URL (v1.4.4 build, workspace is on v1.5.1), missing View type import, and select rows emitted as interfaces which don't satisfy View<T>'s Record<string, unknown> constraint. Regenerates queryTypes.ts.
IDCs
approved these changes
Jul 8, 2026
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.
What
Adds a registered query,
active_profile_nexus_files, that lists thegameId/modId/fileIdfor every installed Nexus mod file of the currently active profile's game — expressed entirely through thelevel_pivotpivot-table system rather than rawkvkey parsing.Query definitions (
src/queries/)setup/tables.sql— three new pivot tables alongside the existing ones:profile_settings_pivot—settings###{section}###{attr}→ exposesactiveProfileIdmod_attributes_pivot—persistent###mods###{game_id}###{vortex_mod_id}###attributes###{attr}→source,modId,fileId,downloadGame(uses a mid-pattern literalattributes###segment;JSON BIGINT/JSON VARCHARcolumn types let the extension unwrap the JSON-encoded values natively)mod_state_pivot—persistent###mods###{game_id}###{vortex_mod_id}###{attr}→state(a top-level mod field, not an attribute)select/nexus_files.sql— the select itself: joins active profile → profile's game → mod attributes + state, filtered tosource = 'nexus'andstate = 'installed'.No runtime code changes were needed for the query itself:
initQuerySystemauto-discovers.sqlfiles, and the nxcopy-assetstarget already trackssrc/queries/as an input.TypeScript changes
All in
scripts/generate-query-types.ts. This is the first parameterless select fed through the generator, which exercised previously-dead code paths and exposed three latent bugs (the generator was unrunnable at HEAD):level_pivotfromhalgari.github.io, whose current release is built for DuckDB v1.4.4; the workspace's@duckdb/node-apiis v1.5.1, soINSTALLhard-failed on the version check. Now usesnexus-mods.github.io(same sourcedownload-duckdb-extensions.tsuses), which serves a v1.5.1 build.Viewimport — parameterless selects get aView<Row>accessor in the generatedModels, but the generated file never imported theViewtype, so the output didn't compile. The import is now emitted whenever a parameterless select exists.interfacerows vsView<T>— select result rows were emitted asinterface, which doesn't satisfyView<T>'sT extends Record<string, unknown>constraint (interfaces have no implicit index signature; type aliases do). Rows are now emitted as type aliases, which also made theas Modelscast increateModelsunnecessary — it's removed (eslint flags it as an unnecessary assertion once the types line up).src/main/src/store/generated/queryTypes.tsis regenerated with the new row types (ProfileSettingsPivotRow,ModAttributesPivotRow,ModStatePivotRow,ActiveProfileNexusFilesRow) and query maps.Known limitation (pre-existing generator design, not introduced here): the generated
createModels()maps parameterless selects todb.createView(name), which assumes a DuckDB VIEW of that name exists — but selects are registered as named queries, notCREATE VIEWs, so that accessor would fail if called. The typedQueryParamsMap/QueryResultMaproute viaQueryRegistry.executeQueryis the working path.Example usage
Executed through the query system (parsed by
queryParser, setup + select run inQueryRegistry.initializeorder) against a real Stardew Valley profile — 100 rows, first 10 shown:Note: an installed collection also matches (
source: "nexus",state: "installed") but identifies viacollectionIdrather thanmodId/fileId, so it returns null ids. Filter withmodId IS NOT NULLif collections should be excluded, or pivotcollectionId/revisionIdin as columns if they should be identified.Verification
pnpm run generate:query-types— succeeds (was broken at HEAD)@vortex/main:build,typecheck,lint,test(233 passed / 4 skipped),format— all cleanqueryParser+ theQueryRegistryexecution semanticsNotes for reviewers
mods_pivotintables.sqlappears mis-shaped for the real key layout (persistent###mods###{mod_id}###{attr}— the{mod_id}capture lands on the game segment, so itsname/version/statecolumns can never match). Nothing references it;mod_state_pivothere demonstrates the correct shape. Left untouched to keep this change narrow — could be fixed or dropped in a follow-up.