@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.
Files changed (97) hide show
  1. package/README.md +19 -4
  2. package/client/asset_bundle/bundle.ts +3 -9
  3. package/client/data/datastore.ts +4 -5
  4. package/client/markdown_parser/constants.ts +5 -4
  5. package/client/plugos/hooks/code_widget.ts +3 -8
  6. package/client/plugos/hooks/command.ts +8 -8
  7. package/client/plugos/hooks/document_editor.ts +10 -15
  8. package/client/plugos/hooks/event.ts +33 -36
  9. package/client/plugos/hooks/mq.ts +17 -17
  10. package/client/plugos/hooks/plug_namespace.ts +3 -8
  11. package/client/plugos/hooks/slash_command.ts +13 -28
  12. package/client/plugos/hooks/syscall.ts +3 -3
  13. package/client/plugos/manifest_cache.ts +22 -15
  14. package/client/plugos/plug.ts +2 -6
  15. package/client/plugos/plug_compile.ts +79 -78
  16. package/client/plugos/protocol.ts +28 -28
  17. package/client/plugos/proxy_fetch.ts +7 -6
  18. package/client/plugos/sandboxes/web_worker_sandbox.ts +1 -1
  19. package/client/plugos/sandboxes/worker_sandbox.ts +18 -18
  20. package/client/plugos/syscalls/asset.ts +1 -3
  21. package/client/plugos/syscalls/code_widget.ts +1 -3
  22. package/client/plugos/syscalls/config.ts +1 -5
  23. package/client/plugos/syscalls/datastore.ts +1 -1
  24. package/client/plugos/syscalls/editor.ts +72 -69
  25. package/client/plugos/syscalls/event.ts +9 -12
  26. package/client/plugos/syscalls/fetch.ts +31 -23
  27. package/client/plugos/syscalls/index.ts +10 -1
  28. package/client/plugos/syscalls/jsonschema.ts +72 -32
  29. package/client/plugos/syscalls/language.ts +9 -5
  30. package/client/plugos/syscalls/markdown.ts +29 -7
  31. package/client/plugos/syscalls/mq.ts +4 -12
  32. package/client/plugos/syscalls/service_registry.ts +1 -4
  33. package/client/plugos/syscalls/shell.ts +2 -5
  34. package/client/plugos/syscalls/space.ts +1 -1
  35. package/client/plugos/syscalls/sync.ts +69 -60
  36. package/client/plugos/syscalls/system.ts +2 -3
  37. package/client/plugos/system.ts +6 -12
  38. package/client/plugos/worker_runtime.ts +12 -33
  39. package/client/space_lua/aggregates.ts +782 -0
  40. package/client/space_lua/ast.ts +42 -8
  41. package/client/space_lua/ast_narrow.ts +4 -2
  42. package/client/space_lua/eval.ts +886 -575
  43. package/client/space_lua/labels.ts +7 -12
  44. package/client/space_lua/liq_null.ts +6 -0
  45. package/client/space_lua/numeric.ts +5 -8
  46. package/client/space_lua/parse.ts +346 -120
  47. package/client/space_lua/query_collection.ts +926 -82
  48. package/client/space_lua/query_env.ts +26 -0
  49. package/client/space_lua/render_lua_markdown.ts +369 -0
  50. package/client/space_lua/rp.ts +5 -4
  51. package/client/space_lua/runtime.ts +288 -155
  52. package/client/space_lua/stdlib/format.ts +53 -39
  53. package/client/space_lua/stdlib/js.ts +3 -7
  54. package/client/space_lua/stdlib/load.ts +1 -3
  55. package/client/space_lua/stdlib/math.ts +84 -58
  56. package/client/space_lua/stdlib/net.ts +27 -17
  57. package/client/space_lua/stdlib/os.ts +81 -85
  58. package/client/space_lua/stdlib/pattern.ts +695 -0
  59. package/client/space_lua/stdlib/prng.ts +148 -0
  60. package/client/space_lua/stdlib/space_lua.ts +17 -23
  61. package/client/space_lua/stdlib/string.ts +102 -190
  62. package/client/space_lua/stdlib/string_pack.ts +490 -0
  63. package/client/space_lua/stdlib/table.ts +76 -16
  64. package/client/space_lua/stdlib.ts +53 -39
  65. package/client/space_lua/tonumber.ts +82 -42
  66. package/client/space_lua/util.ts +53 -15
  67. package/dist/plug-compile.js +55 -98
  68. package/package.json +27 -20
  69. package/plug-api/constants.ts +0 -32
  70. package/plug-api/lib/async.ts +20 -7
  71. package/plug-api/lib/crypto.ts +16 -17
  72. package/plug-api/lib/dates.ts +15 -7
  73. package/plug-api/lib/json.ts +11 -5
  74. package/plug-api/lib/limited_map.ts +1 -1
  75. package/plug-api/lib/native_fetch.ts +2 -0
  76. package/plug-api/lib/ref.ts +23 -23
  77. package/plug-api/lib/resolve.ts +7 -11
  78. package/plug-api/lib/tags.ts +13 -4
  79. package/plug-api/lib/transclusion.ts +10 -21
  80. package/plug-api/lib/tree.ts +165 -45
  81. package/plug-api/lib/yaml.ts +35 -25
  82. package/plug-api/syscalls/asset.ts +1 -1
  83. package/plug-api/syscalls/config.ts +1 -4
  84. package/plug-api/syscalls/editor.ts +15 -15
  85. package/plug-api/syscalls/jsonschema.ts +1 -3
  86. package/plug-api/syscalls/lua.ts +3 -9
  87. package/plug-api/syscalls/mq.ts +1 -4
  88. package/plug-api/syscalls/shell.ts +4 -1
  89. package/plug-api/syscalls/space.ts +3 -10
  90. package/plug-api/syscalls/system.ts +1 -4
  91. package/plug-api/syscalls/yaml.ts +2 -6
  92. package/plug-api/system_mock.ts +0 -1
  93. package/plug-api/types/client.ts +16 -1
  94. package/plug-api/types/event.ts +6 -4
  95. package/plug-api/types/manifest.ts +8 -9
  96. package/plugs/builtin_plugs.ts +2 -2
  97. package/client/plugos/sandboxes/deno_worker_sandbox.ts +0 -6
@@ -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
- name?: string;
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<U, K extends U extends { type: infer T } ? T : never> =
7
- Extract<U, { type: K }>;
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) =>