Commit Graph
2889 Commits
Author SHA1 Message Date
Zef Hemel 405899781e Added journaling guide to website content 2026-03-04 14:23:59 +01:00
Zef Hemel 35542a2cc9 Missing website files, whoops 2026-03-04 13:39:27 +01:00
Zef Hemel 59c271131b Big website content iteration 2026-03-04 13:31:27 +01:00
Zef HemelandGitHub 82f10fa59f Merge pull request #1858 from mjf/space-lua-fix-liq-ordering
[LIQ] Fix `group by`: `order by` with `select` aliases, variable binding in `having` and `nil` column ordering
2026-03-03 10:58:45 +01:00
Zef Hemel ba297f66db Doc tweaks (less duplication of queryies and more use of bound queries) 2026-03-03 10:43:30 +01:00
Matouš Jan Fialka 7cc39ce62f Show null/missing query cells as empty instead of *(null)*
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-03 09:25:45 +01:00
Matouš Jan Fialka b786d65307 [LIQ] Add filter(where <cond>) clause for per-row aggregate filtering
Implements `filter(where <cond>)` for aggregate functions in LIQ
queries which allows per-row conditional filtering within grouped
aggregates. Also extends test suite and documentation.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-03 08:29:18 +01:00
Matouš Jan Fialka e35b61d050 Rename LUA_SQL_NULL to LIQ_NULL
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-02 14:07:07 +01:00
Matouš Jan Fialka 0d49a7b0de [Space Lua] Load scripts without priority last during reload
The new null-aware ordering in `orderByCompare` changed the default
placement of undefined values for descending sorts to `nulls first` (SQL
standard). This caused Space Lua scripts without a `-- priority:`
comment to load before the `Std` library scripts and breaking the boot
sequence for user scripts ran before `schema`, `config`, `widget` and
other core definitions were available.

Add explicit `nulls: "last"` to the reload query so scripts without
priority always load last, matching the documented behavior.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-02 13:44:28 +01:00
Matouš Jan Fialka ff6854f6ee [LIQ] Add nulls first / nulls last to order by
Extend the `order by` clause with optional `nulls first` and `nulls
last` modifiers following standard SQL semantics. Each sort key can
independently specify where `nil` values should appear in the result. By
default, ascending sorts place nulls last and descending sorts place
nulls first. An explicit nulls first or nulls last overrides this
default. The `asc` keyword is also now accepted as an explicit
alternative to the default ascending direction. Documentation and tests
were updated accordingly.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-03-02 12:34:25 +01:00
Zef Hemel f3ed6ec5dd Fixes #1863 2026-03-02 11:46:07 +01:00
Zef HemelandGitHub ad27466268 Merge pull request #1861 from gitlon/patch-1 2026-02-28 06:50:11 +01:00
Matouš Jan Fialka 8f193dc402 [LIQ] Fix: preserve queryable collections in query evaluation
Check for already-queryable objects (e.g. `DataStoreQueryCollection`)
before `LuaTable` extraction or `luaValueToJS` conversion, preventing
them from being destroyed by the collection normalization pipeline.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-27 15:44:26 +01:00
Matouš Jan Fialka cad71aa586 [LIQ] Fix: group by keys and collection handling
- Fix `group by` key building: populate array indices from
  `keyParts` instead of only from `keyRecord`, which was empty for
  some expressions (e.g. `tags[1]`).

- Fix collection handling: treat record-like `LuaTables` (no array part)
  as items instead of extracting zero items.

- Update test suite.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-27 15:30:40 +01:00
Laurence TanandGitHub c8e541250b Fix typo in Library Manager documentation 2026-02-27 19:12:03 +11:00
Matouš Jan Fialka bc2ae5e46f [LIQ] Miscellaneous bugfixes
* Fix `LUA_SQL_NULL` leaking into `order by` comparisons

  Note: SQL `NULLS LAST` is now default behaviour!

* Fix `objectVariable` unset for empty groups

* Fix non-grouped `having` used wrong environment builder

  Note: Queries similar to the following one now works correctly:

  ```sql
  ${query[[
    from
      tags.page
    having
      name == 'index'
  ]]}
  ```

* Fix `generateKey` did not handle `LUA_SQL_NULL`

* Refactor/deduplicate duplicated `order by` comparator

* Add `isSqlNull` helper

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-27 08:37:00 +01:00
Matouš Jan FialkaandGitHub 41b4a5d394 Merge branch 'silverbulletmd:main' into space-lua-fix-liq-ordering 2026-02-27 08:20:09 +01:00
Matouš Jan Fialka f7dc242790 [LIQ] Fix group by: order by with select aliases, variable binding in having and nil column ordering
1. Fix `order by` inability to access `select` output aliases and
   aggregate functions after `group by`.

2. Introduce `LUA_SQL_NULL` sentinel to preserve column ordering when
   `select` expressions evaluate to `nil`.

   Note: In Lua, setting a table key to `nil` deletes it so rows with
   `nil` values lose those keys and produced inconsistent insertion
   order across result tables.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-26 15:32:28 +01:00
Zef Hemel 336e87672f Simplifies #1724
Now considers any HTTP status >= 500 < 600 as offline
2026-02-26 11:39:43 +01:00
Zef HemelandGitHub 8e71ff90eb Merge pull request #1856 from mjf/fix-doc-typo
[LIQ/doc] Fix docs typo
2026-02-26 11:05:16 +01:00
Zef Hemel 8ca97579fb Hide vertical scrolling in page name in case of long page names 2026-02-26 10:15:25 +01:00
Zef Hemel f29f043ff3 Fixes #1846: bring back virtual pages
Was misusing Lua pattern matching before
2026-02-26 09:48:15 +01:00
Zef HemelandGitHub 0f3f963de0 Merge pull request #1833 from rktjmp/feat-upload-no-clobber
Dont clobber existing files when uploading
2026-02-26 09:28:27 +01:00
Oliver Marriott 274780e5e1 Match await flashNotification usage to existing code 2026-02-26 14:56:51 +11:00
Oliver Marriott ea590f8e27 Formatter 2026-02-26 14:27:25 +11:00
Oliver Marriott 4c5598dd4f Swap client.space... to editor.space... 2026-02-26 14:27:25 +11:00
Oliver Marriott 9467e8af26 Convert arrow functions to regular function decls 2026-02-26 14:27:14 +11:00
Matouš Jan Fialka b6d4f71aca [LIQ/doc] Fix docs typo
The `select` part operates not over a single record, but over each group
(i.e., the set of records sharing the same group key). The `select`
clause's environment is generally:

* `name` (the group key)

* `group` (the table of records in the group)

Note: no `p` is bound (`p` is not set; it was the row variable during scan, but we are now at the group level).

In the `select { name = name }` the name refers to the group key (what
we `group by`-ed).

We typically use:

* `name = name` (group key, as in the query), or

* if we want data from the first record (say all grouped `p.name` are
  the same and non-`nil`) then `name = group[1].name`.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-25 10:45:08 +01:00
Zef HemelandGitHub 924f7cacc3 Merge pull request #1852 from mjf/space-lua-add-frexp-and-ldexp
[Space Lua] Add `math.frexp` and `math.ldexp` and tests
2026-02-25 10:38:06 +01:00
Zef HemelandGitHub 89f0e57bfa Merge pull request #1844 from mjf/space-lua-fixtures
[Space Lua] Miscellaneous bug fixes and improvements
2026-02-25 10:37:37 +01:00
Zef HemelandGitHub a347487375 Merge branch 'main' into space-lua-fixtures 2026-02-25 10:36:32 +01:00
13c61ebab7 [LIQ] Extend with group by and having with aggregators (#1843)
* [LIQ] Extend with `group by` and `having` support

Also update documentation with extensive examples and add some parser
tests.

Note: `make generate` JS files included.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Merge `liq-add-support-for-aggregators` branch

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fix link, remove `_` example

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Wrap example LIQ queries inside `query [[ .. ]]` and replace `sql` code block type to `lua`

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Example self-consistency fix

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Fixed some queries

* Add experimental tags to LIQ aggregation/grouping

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Co-authored-by: Zef Hemel <zef@zef.me>
2026-02-25 10:35:31 +01:00
rktjmpandGitHub f4bd2c3abc Trim user input from prompts where appropriate (#1854)
* Trim user input from prompts where appropriate

* Run formatter

* Use "page title" language instead of "page name" in notifications.

Existing language in prompt asks for a "page title".

* Use const for prefix inputs as they are never trimmed
2026-02-25 10:16:37 +01:00
Matouš Jan FialkaandGitHub fd4ff8518d [Space Lua] Implement string.pack, string.unpack and string.packsize (#1851)
The three binary-packing functions from Lua are now implemented in
a dedicated `string_pack.ts` module and wired into `stringApi`.

Format parsing follows the exact option set of Lua:

* signed and unsigned integers of configurable width
  (`b`/`B`/`h`/`H`/`l`/`L`/`j`/`J`/`T`/`i`/`I`),
* IEEE 754 single and double precision floats (`f`/`d`/`n`),
* fixed-length strings (`c`),
* length-prefixed strings (`s`),
* zero-terminated strings (`z`),
* padding bytes (`x`),
* alignment padding (`X`), and
* endianness/alignment modifiers (`<`/`>`/`=`/`!`).

`string.packsize` rejects variable-length formats (`s` and `z`) as Lua
requires.

`string.unpack` returns all unpacked values followed by the
next position integer, matching the Lua contract exactly.

Test suite extended in separates `string_pack_test.lua` file. Passes
both Lua and Space Lua execution.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-25 09:29:14 +01:00
Matouš Jan FialkaandGitHub cebc834469 FIX: Skip nil results in query select to prevent null rows corrupting renderer (#1853)
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-25 09:27:24 +01:00
Oliver Marriott db6f16fa6f Fix typing 2026-02-25 00:00:04 +11:00
Oliver Marriott 037e69c889 Add no-clobber behaviour to paste uploads 2026-02-25 00:00:04 +11:00
Oliver Marriott f22c1ce15c Check user input for null, trim otherwise 2026-02-25 00:00:04 +11:00
Oliver Marriott d8f0a7488b Prompt user before replacing files when using Upload file command 2026-02-25 00:00:04 +11:00
Matouš Jan Fialka 1f36103338 Add math.frexp and math.ldexp and tests
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 14:55:04 +01:00
Matouš Jan Fialka ed8ce174fc [Space Lua] Add _VERSION environment variable
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 13:01:50 +01:00
Matouš Jan Fialka 390fe384c1 [Space Lua] Remove unpack from core language test suite
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 08:24:28 +01:00
Matouš Jan Fialka cc931319d7 [Space Lua] Align table.pack and table.unpack with Lua semantics
`table.pack` now routes element writes through `luaSet` so `__newindex`
metamethods are honoured, matching the exact Lua 5.4 semantics.  The `n`
field is still written with `rawSet`, also matching Lua.

`table.unpack` now returns an empty `LuaMultiRes` instead of `null` for
an empty range `(i > j)`. Returning `null` would inject a single `nil`
argument at the call site; an empty `LuaMultiRes` correctly contributes
zero values, matching the exact Lua semantics.

The global `unpack` shim (for Lua 5.1 compatibility) has been removed
from `luaBuildStandardEnv`. Users who need the short alias can set it up
in `space-script` with a single line stating `unpack = table.unpack`.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 08:16:09 +01:00
Matouš Jan Fialka 11347fee72 Merge on main
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-23 07:33:51 +01:00
Matouš Jan FialkaandGitHub 3bb80ece3f [Space Lua]: Implement math.random and math.randomseed (#1845) 2026-02-21 17:56:49 +01:00
rktjmpandGitHub 472ff93416 Consider "" to be an invalid path (#1847) 2026-02-21 17:55:23 +01:00
Matouš Jan Fialka ef7b128793 [Space Lua] Fix: math.tointeger coerces strings like Lua; fix test
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 15:25:24 +01:00
Matouš Jan Fialka c3b747b0d5 [Space Lua] Fix: t[nil] read returns nil, not an error
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 15:06:22 +01:00
Matouš Jan Fialka 91927a7314 [Space Lua] Fix: Table index is nil/NaN raises error
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 11:27:55 +01:00
Matouš Jan Fialka 559fc0b94d [Space Lua] Implement math.tointeger
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-20 11:26:59 +01:00