@silverbulletmd/silverbullet 2.4.2 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -4
- package/client/asset_bundle/bundle.ts +3 -9
- package/client/data/datastore.ts +4 -5
- package/client/markdown_parser/constants.ts +5 -4
- package/client/plugos/hooks/code_widget.ts +3 -8
- package/client/plugos/hooks/command.ts +8 -8
- package/client/plugos/hooks/document_editor.ts +10 -15
- package/client/plugos/hooks/event.ts +33 -36
- package/client/plugos/hooks/mq.ts +17 -17
- package/client/plugos/hooks/plug_namespace.ts +3 -8
- package/client/plugos/hooks/slash_command.ts +13 -28
- package/client/plugos/hooks/syscall.ts +3 -3
- package/client/plugos/manifest_cache.ts +22 -15
- package/client/plugos/plug.ts +2 -6
- package/client/plugos/plug_compile.ts +79 -78
- package/client/plugos/protocol.ts +28 -28
- package/client/plugos/proxy_fetch.ts +7 -6
- package/client/plugos/sandboxes/web_worker_sandbox.ts +1 -1
- package/client/plugos/sandboxes/worker_sandbox.ts +18 -18
- package/client/plugos/syscalls/asset.ts +1 -3
- package/client/plugos/syscalls/code_widget.ts +1 -3
- package/client/plugos/syscalls/config.ts +1 -5
- package/client/plugos/syscalls/datastore.ts +1 -1
- package/client/plugos/syscalls/editor.ts +72 -69
- package/client/plugos/syscalls/event.ts +9 -12
- package/client/plugos/syscalls/fetch.ts +31 -23
- package/client/plugos/syscalls/index.ts +10 -1
- package/client/plugos/syscalls/jsonschema.ts +72 -32
- package/client/plugos/syscalls/language.ts +9 -5
- package/client/plugos/syscalls/markdown.ts +29 -7
- package/client/plugos/syscalls/mq.ts +4 -12
- package/client/plugos/syscalls/service_registry.ts +1 -4
- package/client/plugos/syscalls/shell.ts +2 -5
- package/client/plugos/syscalls/space.ts +1 -1
- package/client/plugos/syscalls/sync.ts +69 -60
- package/client/plugos/syscalls/system.ts +2 -3
- package/client/plugos/system.ts +6 -12
- package/client/plugos/worker_runtime.ts +12 -33
- package/client/space_lua/aggregates.ts +782 -0
- package/client/space_lua/ast.ts +42 -8
- package/client/space_lua/ast_narrow.ts +4 -2
- package/client/space_lua/eval.ts +886 -575
- package/client/space_lua/labels.ts +7 -12
- package/client/space_lua/liq_null.ts +6 -0
- package/client/space_lua/numeric.ts +5 -8
- package/client/space_lua/parse.ts +346 -120
- package/client/space_lua/query_collection.ts +926 -82
- package/client/space_lua/query_env.ts +26 -0
- package/client/space_lua/render_lua_markdown.ts +369 -0
- package/client/space_lua/rp.ts +5 -4
- package/client/space_lua/runtime.ts +288 -155
- package/client/space_lua/stdlib/format.ts +53 -39
- package/client/space_lua/stdlib/js.ts +3 -7
- package/client/space_lua/stdlib/load.ts +1 -3
- package/client/space_lua/stdlib/math.ts +84 -58
- package/client/space_lua/stdlib/net.ts +27 -17
- package/client/space_lua/stdlib/os.ts +81 -85
- package/client/space_lua/stdlib/pattern.ts +695 -0
- package/client/space_lua/stdlib/prng.ts +148 -0
- package/client/space_lua/stdlib/space_lua.ts +17 -23
- package/client/space_lua/stdlib/string.ts +102 -190
- package/client/space_lua/stdlib/string_pack.ts +490 -0
- package/client/space_lua/stdlib/table.ts +76 -16
- package/client/space_lua/stdlib.ts +53 -39
- package/client/space_lua/tonumber.ts +82 -42
- package/client/space_lua/util.ts +53 -15
- package/dist/plug-compile.js +55 -98
- package/package.json +27 -20
- package/plug-api/constants.ts +0 -32
- package/plug-api/lib/async.ts +20 -7
- package/plug-api/lib/crypto.ts +16 -17
- package/plug-api/lib/dates.ts +15 -7
- package/plug-api/lib/json.ts +11 -5
- package/plug-api/lib/limited_map.ts +1 -1
- package/plug-api/lib/native_fetch.ts +2 -0
- package/plug-api/lib/ref.ts +23 -23
- package/plug-api/lib/resolve.ts +7 -11
- package/plug-api/lib/tags.ts +13 -4
- package/plug-api/lib/transclusion.ts +10 -21
- package/plug-api/lib/tree.ts +165 -45
- package/plug-api/lib/yaml.ts +35 -25
- package/plug-api/syscalls/asset.ts +1 -1
- package/plug-api/syscalls/config.ts +1 -4
- package/plug-api/syscalls/editor.ts +15 -15
- package/plug-api/syscalls/jsonschema.ts +1 -3
- package/plug-api/syscalls/lua.ts +3 -9
- package/plug-api/syscalls/mq.ts +1 -4
- package/plug-api/syscalls/shell.ts +4 -1
- package/plug-api/syscalls/space.ts +3 -10
- package/plug-api/syscalls/system.ts +1 -4
- package/plug-api/syscalls/yaml.ts +2 -6
- package/plug-api/system_mock.ts +0 -1
- package/plug-api/types/client.ts +16 -1
- package/plug-api/types/event.ts +6 -4
- package/plug-api/types/manifest.ts +8 -9
- package/plugs/builtin_plugs.ts +2 -2
- package/client/plugos/sandboxes/deno_worker_sandbox.ts +0 -6
package/client/space_lua/ast.ts
CHANGED
|
@@ -175,7 +175,9 @@ export type LuaExpression =
|
|
|
175
175
|
| LuaUnaryExpression
|
|
176
176
|
| LuaTableConstructor
|
|
177
177
|
| LuaFunctionDefinition
|
|
178
|
-
| LuaQueryExpression
|
|
178
|
+
| LuaQueryExpression
|
|
179
|
+
| LuaFilteredCallExpression
|
|
180
|
+
| LuaAggregateCallExpression;
|
|
179
181
|
|
|
180
182
|
export type LuaNilLiteral = {
|
|
181
183
|
type: "Nil";
|
|
@@ -234,6 +236,7 @@ export type LuaFunctionCallExpression = {
|
|
|
234
236
|
prefix: LuaPrefixExpression;
|
|
235
237
|
name?: string;
|
|
236
238
|
args: LuaExpression[];
|
|
239
|
+
orderBy?: LuaOrderBy[];
|
|
237
240
|
} & ASTContext;
|
|
238
241
|
|
|
239
242
|
export type LuaBinaryExpression = {
|
|
@@ -254,10 +257,7 @@ export type LuaTableConstructor = {
|
|
|
254
257
|
fields: LuaTableField[];
|
|
255
258
|
} & ASTContext;
|
|
256
259
|
|
|
257
|
-
export type LuaTableField =
|
|
258
|
-
| LuaDynamicField
|
|
259
|
-
| LuaPropField
|
|
260
|
-
| LuaExpressionField;
|
|
260
|
+
export type LuaTableField = LuaDynamicField | LuaPropField | LuaExpressionField;
|
|
261
261
|
|
|
262
262
|
export type LuaDynamicField = {
|
|
263
263
|
type: "DynamicField";
|
|
@@ -281,6 +281,20 @@ export type LuaFunctionDefinition = {
|
|
|
281
281
|
body: LuaFunctionBody;
|
|
282
282
|
} & ASTContext;
|
|
283
283
|
|
|
284
|
+
// Aggregate with per-row filter
|
|
285
|
+
export type LuaFilteredCallExpression = {
|
|
286
|
+
type: "FilteredCall";
|
|
287
|
+
call: LuaFunctionCallExpression;
|
|
288
|
+
filter: LuaExpression;
|
|
289
|
+
} & ASTContext;
|
|
290
|
+
|
|
291
|
+
// Aggregate call with intra-aggregate order by
|
|
292
|
+
export type LuaAggregateCallExpression = {
|
|
293
|
+
type: "AggregateCall";
|
|
294
|
+
call: LuaFunctionCallExpression;
|
|
295
|
+
orderBy: LuaOrderBy[];
|
|
296
|
+
} & ASTContext;
|
|
297
|
+
|
|
284
298
|
// Query stuff
|
|
285
299
|
export type LuaQueryExpression = {
|
|
286
300
|
type: "Query";
|
|
@@ -291,13 +305,16 @@ export type LuaQueryClause =
|
|
|
291
305
|
| LuaFromClause
|
|
292
306
|
| LuaWhereClause
|
|
293
307
|
| LuaLimitClause
|
|
308
|
+
| LuaOffsetClause
|
|
294
309
|
| LuaOrderByClause
|
|
295
|
-
| LuaSelectClause
|
|
310
|
+
| LuaSelectClause
|
|
311
|
+
| LuaGroupByClause
|
|
312
|
+
| LuaHavingClause;
|
|
296
313
|
|
|
314
|
+
// Field list used by `from`, `select` and `group by` clauses
|
|
297
315
|
export type LuaFromClause = {
|
|
298
316
|
type: "From";
|
|
299
|
-
|
|
300
|
-
expression: LuaExpression;
|
|
317
|
+
fields: LuaTableField[];
|
|
301
318
|
} & ASTContext;
|
|
302
319
|
|
|
303
320
|
export type LuaWhereClause = {
|
|
@@ -311,6 +328,11 @@ export type LuaLimitClause = {
|
|
|
311
328
|
offset?: LuaExpression;
|
|
312
329
|
} & ASTContext;
|
|
313
330
|
|
|
331
|
+
export type LuaOffsetClause = {
|
|
332
|
+
type: "Offset";
|
|
333
|
+
offset: LuaExpression;
|
|
334
|
+
} & ASTContext;
|
|
335
|
+
|
|
314
336
|
export type LuaOrderByClause = {
|
|
315
337
|
type: "OrderBy";
|
|
316
338
|
orderBy: LuaOrderBy[];
|
|
@@ -320,9 +342,21 @@ export type LuaOrderBy = {
|
|
|
320
342
|
type: "Order";
|
|
321
343
|
expression: LuaExpression;
|
|
322
344
|
direction: "asc" | "desc";
|
|
345
|
+
nulls?: "first" | "last";
|
|
346
|
+
using?: string | LuaFunctionBody;
|
|
323
347
|
} & ASTContext;
|
|
324
348
|
|
|
325
349
|
export type LuaSelectClause = {
|
|
326
350
|
type: "Select";
|
|
351
|
+
fields: LuaTableField[];
|
|
352
|
+
} & ASTContext;
|
|
353
|
+
|
|
354
|
+
export type LuaGroupByClause = {
|
|
355
|
+
type: "GroupBy";
|
|
356
|
+
fields: LuaTableField[];
|
|
357
|
+
} & ASTContext;
|
|
358
|
+
|
|
359
|
+
export type LuaHavingClause = {
|
|
360
|
+
type: "Having";
|
|
327
361
|
expression: LuaExpression;
|
|
328
362
|
} & ASTContext;
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
import type { ASTCtx, LuaExpression, LuaLValue, LuaStatement } from "./ast.ts";
|
|
4
4
|
|
|
5
5
|
// Extract by `type` discriminant
|
|
6
|
-
type NarrowByType<
|
|
7
|
-
|
|
6
|
+
type NarrowByType<
|
|
7
|
+
U,
|
|
8
|
+
K extends U extends { type: infer T } ? T : never,
|
|
9
|
+
> = Extract<U, { type: K }>;
|
|
8
10
|
|
|
9
11
|
// Expressions
|
|
10
12
|
export const asStringExpr = (e: LuaExpression) =>
|