feat(bedrock-project): SqliteDataSet<T> POC — sql.js-backed drop-in for DataSet<T>#339
Draft
feat(bedrock-project): SqliteDataSet<T> POC — sql.js-backed drop-in for DataSet<T>#339
Conversation
Agent-Logs-Url: https://github.com/Blockception/minecraft-bedrock-language-server/sessions/1fea08ef-cdcf-4712-94b4-a5e4a6bc1f0d Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Create proof-of-concept for SqliteDataSet implementation
feat(bedrock-project): SqliteDataSet<T> POC — sql.js-backed drop-in for DataSet<T>
Mar 26, 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.
Introduces a proof-of-concept
SqliteDataSet<T>backed by sql.js (SQLite → WASM), enabling a future path to replace the in-memoryMap-backedDataSet<T>with a queryable store that works on all platforms includingvscode.dev.Implementation
sqlite-data-set.ts—SqliteDataSet<T>implements the sameDataSetBase+IDataSet<T>interfaces asDataSet<T>; async factorySqliteDataSet.create(tableName, db?)handles sql.js initid TEXT PRIMARY KEY,uri TEXT NOT NULL,data TEXT NOT NULL+ index onuri; full object stored as JSON indatadeleteFile/deleteFolderuse SQLWHERE uri = ?/WHERE uri LIKE ? || '%'instead of full-Map iterationdbparameter allows multiple datasets to share a single in-memoryDatabaseinstancePackage changes
packages/bedrock-project/package.json— addssql.js ^1.12.0(dep) and@types/sql.js ^1.4.9(devDep)packages/bedrock-project/src/types/index.ts— re-exportsSqliteDataSetpackages/bedrock-project/src/types/sqlite-data-set.test.ts— Jest suite mirroringdata-set.test.ts, covering all 11 operations plus shared-DB usageOriginal prompt
Goal
Create a proof-of-concept (POC) for replacing the in-memory
DataSet<T>(backed byMap<string, T>inpackages/bedrock-project/src/types/data-set.ts) with a sql.js-backedSqliteDataSet<T>that:DataSetBase+IDataSet<T>interfacesvscode.dev(browser/web extension) with no native binariesSqliteDataSet.create(tableName)) since sql.js initialisation is asyncdata TEXTcolumn, plus separate indexed columns forid TEXTanduri TEXT— makingdeleteFileanddeleteFolderefficient SQL operations instead of full-Map iterationsqlite-data-set.test.ts) that mirrorsdata-set.test.tsand covers all operationsLocation
All new files should live inside the existing package:
Also update:
If
packages/bedrock-project/src/types/index.tsdoes not exist, checkpackages/bedrock-project/src/types.tsor the barrel exports and add the export there appropriately.Implementation details
SqliteDataSet<T extends Identifiable & Locatable>Schema (per table)
Serialisation
set(value)→JSON.stringify(value)intodataget(id)→JSON.parse(row.data)back toTdeleteFoldersemanticsMatch the existing
DataSet.deleteFolderbehaviour: delete all rows whereitem.location.uri.startsWith(uri). Implement as:DELETE FROM <table> WHERE uri LIKE ? || '%'with the folder URI as the parameter — this is correct for URI prefix matching in practice (file URIs don't contain SQL wildcards).static async createbehaviourThe caller is responsible for sharing/closing the
Databaseinstance if needed. For the POC, eachSqliteDataSetowns its own in-memory DB unless one is passed in.Test file (
sqlite-data-set.test.ts)Cover the following scenarios (use the same concrete fake type as
data-set.test.tsuses, i.e.{ id: string, location: { uri: string }, documentation: string }):set+get— round-trips a typed object through JSONhas— returns true/false correctlydelete— removes by id; returns true if deleted, false if not founddeleteFile— removes all items with matchinguri; returns truedeleteFolder— removes all items whoseuristarts with the folder path; returns trueforEach— iterates all itemsfind— finds item by predicatecount— returns number of stored itemsclear—...This pull request was created from Copilot chat.
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.