vastgrid-spec
v0.4.0
Published
The vastgrid specification as code: types, plan checking, the commands of the document and session, the normal form and hash of plans, the message schemas, and the conformance corpus.
Maintainers
Readme
vastgrid-spec
The vastgrid specification as code: the types,
plans, state, commands and messages that vastgrid and its engines
share. The grid depends on it, and an engine of your own uses it to check what it receives and to pass the
conformance corpus.
npm install vastgrid-spec- Plans (§4):
checkPlan(plan, columns)checks a plan against a table's columns and gives the typed tree that engines run, or throws aPlanErrorwith thepathandreasonof the problem.normalizePlan,canonicalJsonandplanHashgive a plan's normal form and hash. - Values (§2):
floatText,textOf,isValueOfand the other helpers ofvalues.tsandcalendar.tsfollow the rules of values and their text forms. Typed JSON must fit its Arrow representation: signed timestamp/interval counts, well-formed Unicode and already-rounded float32 numbers.readCellTextrounds float32 input and rejects overflow;encodeBlockrefuses invalid values with aBlockValueErrorand a/rows/{row}/{column}path instead of silently changing them. - State (§5):
checkDocumentandcheckSessioncheck the two parts of the state,displayedColumnsgives the display order,repairDocumentfits a document to a table, andmigrateGridStatemigrates 0.1'sGridState. - Commands (§6, §7):
applyCommand(state, command, context)applies a command and gives the new state, the requests the core sends and the output, or throws aCommandError. The new state keeps the objects of what the command does not change, and a command costs nothing for the parts it does not touch (an undo history of a million updates is not copied when the active cell moves).GridCommandtypes every command and its arguments.readCellTextreads typed text, andtoTsv,parseTsv,parseHtmlTableand the others ofclipboard.tscopy and paste. - Messages (§8):
checkRequest,checkResponseandcheckEventcheck messages;encodeBlockanddecodeBlockwrite and read Arrow blocks, andintegerJsonanddecimalJsongive the typed JSON of a 64-bit integer and of an unscaled decimal (§2.2);toTextEncoding,frameAttachedandreadAttachedcarry blocks on transports. vastgrid-spec/columnsreads Arrow tables of any number of record batches as columns (§2.3):decodeColumnsgives each column's typed JSON by row, read when it is asked for, and the typed arrays that hold values of fixed width. It is a module of its own so that bundles that read only blocks do not load it.vastgrid-spec/exportandvastgrid-spec/xlsxwrite the files ofexport(§8.2) from batches of rows of typed JSON, as streams of bytes:writeDelimitedCSV and TSV andwriteJsonJSON as DuckDB'sCOPYwrites them, andwriteXlsxa workbook of one sheet (compressed bywebDeflate, the platform'sCompressionStream, or a deflate of the host's). Both engines write their files with them.vastgrid-spec/workbookreads Excel workbooks (.xlsx,.xlsm) for engines:readWorkbooklists the sheets, andconvertSheetwrites a sheet as lines of CSV with one logical type per column (by its cells and their number formats, in the workbook's calendar), and the notes of what a table cannot keep (merged cells, formulas without saved values). It reads through aWorkbookSourceof ranges of bytes and of inflated text:blobSourcemakes one of aBlobwith the platform'sDecompressionStream, and the DuckDB engine one of a file withnode:fsandnode:zlib. Both engines read workbooks with it.vastgrid-spec/conformancereads the corpus inconformance/and runs or compares its cases (§10). It uses Node.js. The corpus has three parts:plansfor engines,commandsfor cores andmessagesfor both.schema/holds the JSON Schemas of plans, states, commands, messages and the corpus files.
Every engine runs the plan cases: vastgrid-sql runs them on DuckDB,
and vastgrid-js in memory. Every core runs the command
cases: this package's applyCommand runs them.
